You could use XmlDocument.GetElementsByTagName Method to get all descendant elements that match the specified Name, then you could get the InnerText of those elements as below.
XmlDocument ReadInDocument = new XmlDocument();
ReadInDocument.Load(Server.MapPath("~/newsml29.xml"));
XmlNodeList nodeList = ReadInDocument.GetElementsByTagName("hl1");
foreach (XmlNode node in nodeList)
{
string text = node.InnerText.ToString();
Response.Write(text);
}
Best Regards,
Fei Han
xmlasp.net
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
6 Points
20 Posts
xml file read and write
Feb 26, 2015 07:57 AM|fabregas42|LINK
Hi
I have a xml file as follows.
I just headline (HL1), abstract, I want to receive the information in body.content tag.
xml asp.net
All-Star
40565 Points
6233 Posts
Microsoft
Re: xml file read and write
Feb 27, 2015 12:45 AM|Fei Han - MSFT|LINK
Hi fabregas42,
Thanks for your post.
You could use XmlDocument.GetElementsByTagName Method to get all descendant elements that match the specified Name, then you could get the InnerText of those elements as below.
Best Regards,
Fei Han
xml asp.net