0
我想从一个XML文件复制(元素/属性)值到另一个,但目前我无法弄清楚如何去做。我有我想要复制到文件B的文件A中的值。文件B具有相同的元素/属性或多或少与唯一的区别是空的。我采用这种方法,因为我没有这两个文件的模式。如何复制XML文件
以下是文件中的内容:继
<status>1</status>
<arguments>
<argument name="ZONE">
<value>ZONE 1</value>
</argument>
<argument name="JOB_DATES">
<argument name="JOB_DATE">
<value>2014-01-20</value>
</argument>
</argument>
<argument name="PERSON">
<argument name="NAME_1">
<value>JOHN</value>
</argument>
<argument name="NAME_2">
<value>SMITH</value>
</argument>
</argument>
<argument name="FIRST_SCHEDULE_JOB">
<value>true</value>
</argument>
<argument name="EMPLOYEE">
<value>ABXX011</value>
</argument>
</arguments>
<place placeType="JOB_SITE">
<site>
<street>DUKE 2</street>
<house_name>TECH HOUSE</house_name>
<zip>QZ12324</zip>
<city>NYC</city>
<province>NY</province>
<country>USA</country>
</site>
<contact>
<Name>JOHN</Name>
<Name_1>SMITH</Name_1>
<address>
<street>DUKE 2</street>
<house_name>TECH HOUSE</house_name>
<zip>QZ12324</zip>
<city>NYC</city>
<province>NY</province>
<country>USA</country>
</address>
</contact>
是文件B的内容:
<status></status>
<arguments>
<argument name="ZONE">
<value></value>
</argument>
<argument name="JOB_DATES">
<argument name="JOB_DATE">
<value></value>
</argument>
</argument>
<argument name="PERSON">
<argument name="NAME_1">
<value></value>
</argument>
<argument name="NAME_2">
<value></value>
</argument>
</argument>
<argument name="FIRST_SCHEDULE_JOB">
<value></value>
</argument>
<argument name="EMPLOYEE">
<value></value>
</argument>
</arguments>
<place placeType="JOB_SITE">
<contact>
<Name></Name>
<Name_1></Name_1>
<address>
<street></street>
<house_name></house_name>
<zip></zip>
<city></city>
<province></province>
<country></country>
</address>
</contact>
<site>
<street></street>
<house_name></house_name>
<zip></zip>
<city></city>
<province></province>
<country></country>
</site>
</place>
我想通过要素循环的文件B并填写来自文件A的值即: ZONE元素(属性ZONE)填充了ZONE 1值。
我曾尝试与XmlTextReader的,但没有过迄今为止任何运气:
while (emptyFile.Read())
{
switch (emptyFile.NodeType)
{
case XmlNodeType.Element: // The node is an element.
emptyFile.Name = sourceFile.Name;
........
}
}
一些帮助是极大的赞赏
感谢
请包括你已经尝试过在你的问题 - 至少是如果显示您正在使用读取XML该技术的人! – Liath
什么似乎是问题呢?如果你有你的节点,只需将它们写入其他文件。 –
可能的重复[如何将一个XML块从一个文档复制到另一个?](http://stackoverflow.com/questions/12641206/how-can-i-copy-a-block-of-xml-从一个文件到另一个) –