Jump to content

Help With Extracting Xml Namespaces From Xml Data C#


Recommended Posts

Posted

Guys,

Need help in extracting xml namespaces from xml data.

 

<tns:Request xmlns:tns="http://Employee/Info/2013/23/">

    <tns:Name>Employee Name<tns:Name>

    <tns:Age>12<tns:Age>

    <tns:Address>

        <abs:City xmlns:abs="http://Employee/Address/Info/2013/23/">Portland</abs:City>
        <abs:Line1 xmlns:abs="http://Employee/Address/Info/2013/23/">Beavrton Rd</abs:Line1>
        <abs:Line2 xmlns:abs="http://Employee/Address/Info/2013/23/">apt234</abs:Line2>
        <abs:PostalCode xmlns:abs="http://Employee/Address/Info/2013/23/">96004</abs:PostalCode>
      </tns:Address>

</tns:Request>

 

I am able to extract the namespace in the root attribute (i.e. tns="http://Employee/Info/2013/23/" which is part of Request element) using below code, 

sourceData contains xmldata.

 

                XPathDocument XPathDoc = new XPathDocument(new StringReader(sourceData));
                var XNav = XPathDoc.CreateNavigator();
 
                // Extract namespaces
                XNav.MoveToFollowing(XPathNodeType.Text);
                IDictionary<string, string> namespaceList = XNav.GetNamespacesInScope(XmlNamespaceScope.All);
 
 
 
 
can you help me in getting "abs="http://Employee/Address/Info/2013/23/" this namespace also...
Posted

ante enteee

 

DB ki Kesarakka ni parichayam chesina mahanubhavudu ani..Pth8e6c.gif

×
×
  • Create New...