使用XML Document读取XML节点 [英] reading XML Nodes by using XML Document

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

问题描述

我有一个这样的XML文件有很多节点,比如我在下面给出的如何读取节点名称可以帮助我。



 <? xml version =   1.0  encoding =   utf-8  ?>  

< Argonaut >

< add key = SMTP_Port value = < span class =code-attribute> type = URL / >
< add key = LocationMapUrl value = 类型 = 网址 / >
< add key = Easting value = < span class =code-attribute> type = NUMERIC / >
< add key = Northing type = NUMERIC / < span class =code-keyword>>
< add key = LINES_URL value = type = 网址 / < span class =code-keyword>>

< / Argonaut >


< < span class =code-leadattribute> Webservice >

< add key = MapCenterX value = type = NUMERIC / >
< add key = MapCenterY value = type = N UMERIC / >
< add key = Radius value = 类型 = NUMERIC / >
< ; add key < span class =code-keyword> =
DataRefreshMinutes value = type = NUMERIC / >

< / Webservice >

解决方案

您好b $ b

阅读 xml 如果您有更多关于每种解决方案的信息,请提供更多解决方案。



以最简单的方式在C#中使用XML [ ^ ]

http://www.codegain.com/articles/xml/howto/how-to-read -xml-document-in-c-sharp.aspx [ ^ ]

http://support.microsoft.com/kb/307548 [ ^ ]

http://www.c -sharpcorner.com/UploadFile/mahesh/ReadWriteXMLTutMellli2111282005041517AM/ReadWriteXMLTutMellli21.aspx [ ^ ]



最好的问候。


班级系统。 Xml.XmlDocument System.Xml.XmlNode 。因此,您可以递归使用以下属性:

http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.firstchild.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.nextsibling.aspx [ ^ ],

名称: http://msdn.microsoft。 com / en-us / library / system.xml.xmlnode.name.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.localname.aspx [ ^ ]。



另请参阅: http:// msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [ ^ ]。



-SA

i had a XML file like this there are many nodes like i given below how to read that nodes names can any one help me.

<?xml version="1.0" encoding="utf-8" ?>

<Argonaut>
      
     <add key="SMTP_Port" value="" type="URL"/>
     <add key="LocationMapUrl" value="" type="URL"/>
     <add key="Easting" value="" type="NUMERIC"/>
     <add key="Northing" type="NUMERIC"/>
     <add key="LINES_URL" value="" type="URL"/>
    
</Argonaut>


<Webservice>
             
     <add key="MapCenterX" value="" type="NUMERIC"/>
     <add key="MapCenterY" value="" type="NUMERIC"/>
     <add key="Radius" value="" type="NUMERIC"/>
     <add key="DataRefreshMinutes" value="" type="NUMERIC"/>
 
  </Webservice>

解决方案

Hi
For read the xml file you have a more solutions follow of links for get more information about each solution.

Using XML in C# in the simplest way[^]
http://www.codegain.com/articles/xml/howto/how-to-read-xml-document-in-c-sharp.aspx[^]
http://support.microsoft.com/kb/307548[^]
http://www.c-sharpcorner.com/UploadFile/mahesh/ReadWriteXMLTutMellli2111282005041517AM/ReadWriteXMLTutMellli21.aspx[^]

Best Regards.


The class System.Xml.XmlDocument is System.Xml.XmlNode. So you can use the following properties, recursively:
http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.firstchild.aspx[^],
http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.nextsibling.aspx[^],
name: http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.name.aspx[^],
http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.localname.aspx[^].

See also: http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].

—SA


这篇关于使用XML Document读取XML节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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