Tuesday, 29 December 2015

XML : need to read single node in the xml that hase namespace defined

  <?xml version="1.0" encoding="UTF-8"?>  <tns:McsConnectionArray xmlns:p="http://www.atrias.be/Mecoms/DataTypes"    xmlns:p1="http://www.ABC.be/Mecoms/BaseEnums" xmlns:t="http://www.ABC.be/Mecoms/Tables" xmlns:tns="http://www.ABC.be/Mecoms/ManageHeadpointOut/SubmitVolume" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ABC.be/Mecoms/ManageHeadpointOut/MYFILE ManageHeadpointOut.MYFILE.xsd ">   <McsConnectionNode>      <McsConnectionMemberArray>        <McsConnectionMemberNode>          <McsConnectionMember>           <Id>miwt-000007</Id>           <EndDateTime>2015-08-01T12:00:00</EndDateTime>           <StartDateTime>2015-07-01T12:00:00</StartDateTime>        </McsConnectionMember>    </McsConnectionMemberNode>  </McsConnectionMemberArray>    

I need the value Id and move that to a string varible ,

code i wrote in c#

   XmlDocument doc = new XmlDocument();    doc.Load(@"C:\Users\t.mahidharreddy\Desktop\ABC.xml");    XmlNode node = doc.SelectSingleNode("/tns:McsConnectionArray/McsConnectionNode/McsConnectionMemberArray/McsConnectionMemberNode/McsConnectionMember/Id");  string Id = node.InnerText;    

Getting following error

Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.

Thanks in Advance.

No comments:

Post a Comment