I am unable to read the namespace in a XML file. I need the value Id and store that in a string variable.
<?xml version="1.0" encoding="UTF-8"?> <tns:Connectionpoint xmlns:p="http://www.abc.be/abc/Data" xsi:Location="http://www.ABC.be/abc/ABC/MYFILE Managet.MYFILE.xsd "> <Connection> <ABC> <XYZ> <PQR> <Id>DUMMY</Id> <EndTime>2015-08-01112:00:00</EndTime> <StartTime>2015-07-01112:00:00</StartTime> </PQR> </XYZ> </ABC> I have tried the following way
XmlDocument doc = new XmlDocument(); doc.Load(@"C:\Users\t.mahidharreddy\Desktop\ABC.xml"); XmlNode node = doc.SelectSingleNode("/tns:Connection/ABC/XYZ/PQR/Id"); string Id = node.InnerText; I am getting the following error:
Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.
No comments:
Post a Comment