Hi, I'm trying to parse the following XML and am struggling to get the inner text from the URL node, I thought this would work "@newsRelease["PDF"].["URL"].Value.ToString()" but it returns SYSTEM.XML.XMLELEMENT.["URL"].VALUE.TOSTRING().
Here's the rest of the code if it helps, InnerText returns SYSTEM.XML.XMLELEMENT.["URL"].INNERTEXT.
@{ //For each item node we can then ouput what we want
foreach (XmlNode node in feedItems) { var newsReleases = node.SelectNodes("NewsRelease"); foreach (XmlNode newsRelease in newsReleases) { string releaseDate = @newsRelease["Date"].Attributes["Date"].Value; int year = int.Parse(releaseDate.Substring(0, 4)); int month = int.Parse(releaseDate.Substring(4, 2)); int day = int.Parse(releaseDate.Substring(6, 2)); DateTime releaseDateTime = new DateTime(year, month, day);
Parse XML - Get Node 2 Levels Down
Hi, I'm trying to parse the following XML and am struggling to get the inner text from the URL node, I thought this would work "@newsRelease["PDF"].["URL"].Value.ToString()" but it returns SYSTEM.XML.XMLELEMENT.["URL"].VALUE.TOSTRING().
Any thoughts?
Here is the XML.
Thank you,
Amir
Maybe it would help if you can post your entire code for parsing the xml ?
Dave
Think you are perhaps just after XmlNode.innerText?
http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.innertext%28v=vs.110%29.aspx
Here's the rest of the code if it helps, InnerText returns SYSTEM.XML.XMLELEMENT.["URL"].INNERTEXT.
I think you need @newsRelease["URL].InnerText instead of @newsRelease.["URL].InnerText
Hi Dave, that's actually what I had in the code above, the issue was it wasn't looking under the PDF node for the URL node.
Here's what worked: @newsRelease.SelectSingleNode("PDF").SelectSingleNode("URL").InnerText
Thanks,
Amir
is working on a reply...