从xml文件中提取xml节点 [英] extract xml node from xml file

查看:143
本文介绍了从xml文件中提取xml节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

i有这样的xml文件



 <  项目 >  
< ID > 1 < / ID >
< ItemNo > 100 < / ItemNo >
< ItemName > Galaxsy Asc < / ItemName >
< / Item >



和下面的另一个xml文件

 <  项目 >  
< ID > 2 < < span class =code-leadattribute> / Id >
< > 2 < < span class =code-leadattribute> /否 >
< 数量 > 3 < < span class =c ode-leadattribute> / Qty >
< ItemId > 1 < / ItemId >





i想要

 <  数量 >  3 <   / Qty  >  

并在第一个xml文件中添加类似

 <  项目 >  
< ID > 1 < < span class =code-leadattribute> / ID >
< ItemNo > 100 < < span class =code-leadattribute> / ItemNo >
< ItemName > Galaxsy Asc < / ItemName >
< 数量 > 3 < /数量 >
< / Item >





i编写了一个代码但是提取了Qty本身的值3而不是整个节点。



任何人都可以帮助我请



谢谢

解决方案





这可能会对你有所帮助。



http://stackoverflow.com/questions/10033173/how-can-i-find-a-specific-node-in-my-xml [<一个href =http://stackoverflow.com/questions/10033173/how-can-i-find-a-specific-node-in-my-xmltarget =_ blanktitle =New Window> ^

hi all,
i have xml file like this

<Item>
    <ID>1</ID>
    <ItemNo>100</ItemNo>
    <ItemName>Galaxsy Asc</ItemName>  
  </Item>


and another xml file like below

<Item>    
    <Id>2</Id>
    <No>2</No>  
    <Qty>3</Qty>
    <ItemId>1</ItemId>



i want to take

<Qty>3</Qty>

and add in in the first xml file to be like

<Item>
    <ID>1</ID>
    <ItemNo>100</ItemNo>
    <ItemName>Galaxsy Asc</ItemName> 
    <Qty>3</Qty> 
  </Item>



according to ItemId.
i have written a code but extracting the value of Qty itself "3" not the whole node .

can any one helps me in this please

thanks

解决方案

Hi,

this might help you.

http://stackoverflow.com/questions/10033173/how-can-i-find-a-specific-node-in-my-xml[^]


这篇关于从xml文件中提取xml节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆