-- 把数据保存成 xml 格式
fn bipXml bipPaths frames filePath=
(
if bipPaths.count >0 then
(
XmlDocumentXDoc = dotNetobject "System.Xml.XmlDocument"
dotnetPath = dotNetClass "System.IO.Path"
dotnetDirectory =dotNetClass "System.IO.Directory"
dotnetFile = dotNetClass "System.IO.File"
DirFile =dotnetPath.GetDirectoryName (filePath)
if dotnetDirectory.Exists (DirFile) then --尊在不存在都要进行 这里应该判断目录是不是存在
(
--- 第一个节点在外边建立
dotnetNode = XmlDocumentXDoc.CreateNode ((dotNetClass "System.Xml.XmlNodeType").Element) "Url:bipdate" "Url:date"
dotnetNode.InnerText =""
XmlDocumentXDoc.AppendChild (dotnetNode)
--fileName = dotnetPath.GetFileName(filePath) 这里不是用于到这里 而是加入bipPaths 数据
for i in 1 to bipPaths.count do
(
--- 在这里建立字符串
---建立元素
dotnetXmlElement = XmlDocumentXDoc.CreateElement("node")
dotnetXmlElement.InnerText = bipPaths[i]--- 元素的数据进行保存处理
--- 建立属性
---1. bip的名称 2.开始的帧数
bipFileName = dotnetPath.GetFileName(bipPaths[i])
XmlAttributer = XmlDocumentXDoc.CreateAttribute ("bipname")
XmlAttributer.InnerXml = bipFileName ---建立第一个属性
-- 元素加入第一个属性
dotnetXmlElement.SetAttributeNode (XmlAttributer)
---建立第二个属性帧数 //该属性可写入0 帧 可以不写
if frames.count ==0 then
(
XmlAttributerFrame = XmlDocumentXDoc.CreateAttribute("frame")
XmlAttributerFrame.InnerXml = "0"
dotnetXmlElement.SetAttributeNode XmlAttributerFrame
)else
(
XmlAttributerFrame = XmlDocumentXDoc.CreateAttribute("frame")
XmlAttributerFrame.InnerXml = frames[i] as string
dotnetXmlElement.SetAttributeNode XmlAttributerFrame
)
--- 上面是一个元素两个属性建立模型完成 下面就是把 节点元素 插入到 根节点中
---上面一键加入了子 应该是在第一个元素下加入 DocumentElement
XmlDocumentXDoc.DocumentElement.AppendChild (dotnetXmlElement)
)
--- 组后对根节点进行保存处理
XmlDocumentXDoc.save(filePath)
)
)
)