[英]How to retrieve particular data from xml file using c#
作為我的Api功能測試的一部分,我想使用C#刪除給定xml的“ body”部分。 我怎樣才能做到這一點?
這是我的xml文件
<Root>
<collection> </collection>
<run>
<stats> </stats>
<execution>
<cursor> </cursor>
<response>
<body> Some Values here </body>
</response>
</execution>
</run>
</Root>
首先將您的xml加載到XmlDocument對象中,然后使用GetElementsByTagName("body")
可以獲取Node語句主體
XmlDocument _LocalInfo_Xml = new XmlDocument();
_LocalInfo_Xml.Load(_LocalInfo_Path);
XmlElement _XmlElement;
_XmlElement = _LocalInfo_Xml.GetElementsByTagName("body")[0] as XmlElement;
string Value = _XmlElement.InnerText;
現在,值包含您的正文
這里有些值
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.