Handling namespaces in xpath queries
I have an xml document that starts <?xml version="1.0" encoding="utf-8"?> <LOGICALMODEL xmlns="urn:bt-cssschema"> <LOGICALNODE> <VarType>DP</VarType>
I want to read nodes from it using c#. If I create an xpath and read it like this: string xpathQuery = "/LOGICALMODEL/LOGICALNODE[VarType='DP']"; System.Xml.XmlNodeList list = m_xmlDoc.SelectNodes(xpathQuery);
The list is empty. If I edit the xml so that it doesn't have the xmlns part, then the list gets all the nodes I would expect it to. Can anyone please tell me how I can modify the code so that it gets the logical nodes when the xmlns attribute is present in the input file?
Thanks
Steve Started By SteveClay on Jan 27, 2006 at 4:33:51 AM |