NodeList.SelectSingleNode() syntax

oporgrxuwf

New Member
Having problems getting NodeList.SelectSingleNode() to work properly.My XML looks like this:\[code\]<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?><inm:Results xmlns:inm="http://www.namespace.com/1.0"> <inm:Recordset setCount="18254"> <inm:Record setEntry="0"> <!-- snip --> <inm:Image>fileName.jpg</inm:Image> </inm:Record> </inm:Recordset></inm:Results>\[/code\]The data is a long series of \[code\]<inm:Record>\[/code\] entries.I open the doc and get create a NodeList object based on "inm:Record". This works great.\[code\]XmlDocument xdoc = new XmlDocument();xdoc.Load(openFileDialog1.FileName);XmlNodeList xRecord = xdoc.GetElementsByTagName("inm:Record");\[/code\]I start looping through the NodeList using a for loop. Before I process a given entry, I want to check and see if the \[code\]<inm:Image>\[/code\] is set. I thought it would be super easy just to do\[code\]string strImage = xRecord.SelectSingleNode("inm:Image").InnerText;\[/code\]My thinking being, "For the XRecord that I'm on, go find the \[code\]<inm:Image>\[/code\] value ...But this doesn't work as I get the exception saying that I need a XmlNameSpaceManager. So, I tried to set that up but could never get the syntax right.Can someone show me how to use the correct XmlNameSpaceManager syntax in this case.I've worked around the issue for now by looping through all of the childNodes for a given xRecord, and checking the tag once I loop around to it. I would like to check that value first to see if I need to loop over that \[code\]<inm:Record>\[/code\] entry at all.
 
Back
Top