问题描述
嗨
我有一个嵌套的XML结构
<?xml version =" 1.0" standalone =" yes"?>
< UpdateStructure>
<文件>
< FileStructure>
< FileName> MyFile1.exe< / FileName>
< ZipName> ; MyFile1.zip< / ZipName>
< / FileStructure>
< FileStructure>
< FileName> MyFile2.exe< / FileName>
< ZipName> MyFile2.zip< / ZipName> ;
< / FileStructure>
< / File>
< / UpdateStructure>
我可以在readxml的数据集中添加它并将其绑定到gridview 。网格看起来还不错。当我更改名称并使用数据集writexml命令保存XML时,XML文件可以更新。但是,当我向网格添加新行并保存它时,新的XML文件是错误的。它看起来像这样
<?xml version =" 1.0" standalone =" yes"?>
< UpdateStructure>
<文件>
< FileStructure>
< FileName> MyFile1.exe< / FileName>
< ZipName> ; MyFile1.zip< / ZipName>
< / FileStructure>
< FileStructure>
< FileName> MyFile2update.exe< / FileName>
< ZipName> MyFile2.zip< / ZipName> ;
< / FileStructure>
< / File>
< FileStructure>
< FileName> MyFile3.exe< / FileName>
< ZipName> MyFile3.zip< / ZipName>
< / FileStructure>
< / UpdateStructure>
正如您所看到的,它不会将FileStructure放置在File节点中。
如何解决这个问题?
Peter
Hi
I have a nested XML structure
<?xml version="1.0" standalone="yes"?>
<UpdateStructure>
<File>
<FileStructure>
<FileName>MyFile1.exe</FileName>
<ZipName>MyFile1.zip</ZipName>
</FileStructure>
<FileStructure>
<FileName>MyFile2.exe</FileName>
<ZipName>MyFile2.zip</ZipName>
</FileStructure>
</File>
</UpdateStructure>
I can laod this in a dataset with readxml and bind it to a gridview. The grid looks okay. When i alter a name and save the XML with the dataset writexml command the XML file updates okay.
However, when i add a new row to the grid and save it the new XML file is wrong. It just looks like this
<?xml version="1.0" standalone="yes"?>
<UpdateStructure>
<File>
<FileStructure>
<FileName>MyFile1.exe</FileName>
<ZipName>MyFile1.zip</ZipName>
</FileStructure>
<FileStructure>
<FileName>MyFile2update.exe</FileName>
<ZipName>MyFile2.zip</ZipName>
</FileStructure>
</File>
<FileStructure>
<FileName>MyFile3.exe</FileName>
<ZipName>MyFile3.zip</ZipName>
</FileStructure>
</UpdateStructure>
As you can see it does not place the FileStructure in the File node.
How can this be solved?
Peter
推荐答案
这篇关于在网格中添加数据时编写嵌套XML会出错。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!