0

I have the below xml file

    <ins:instrument xmlns:ins="http://instrument" xsi:type="ins:Infra">
    <ins:name>ABC</ins:name>
    <ins:basket>
    <ins:instrument>
     <ins:name>EFG</ins:name>
      </ins:instrument>
     </ins:basket>
     </ins:instrument>

I am using the below code to retrieve only the instrument node which has a xsi:type ="ins:infra"

        XmlDocument configDoc = new XmlDocument();
        configDoc.Load(inputFile);
        XmlNodeList projectNodes = configDoc.GetElementsByTagName("ins:instrument);

I am expecting only one node which has a xsi:type="ins:Infra",But i recieve two ins:instrument nodes. I am using GetElementsByTagName since Its easy to remove a node from the document and save it this way.

How can i fix this issue.

BSB
  • 87
  • 1
  • 1
  • 6
  • the XML given is not valid (UE parse failed - not the best test, but check your ending tags) - is there a more complete xml, otherwise therein lies the issue (there ARE after all 3 ins:instrument tags posted in your example (2 nested in one) and only one matching close – John Mar 16 '17 at 20:58
  • My bad.Forgot to close the ins:instrument tag in the end.Changed the code. – BSB Mar 16 '17 at 21:11

0 Answers0