Link to home
Start Free TrialLog in
Avatar of Vivek Agarwal
Vivek AgarwalFlag for India

asked on

XML child tag read in C#

How to read Child tags under parent tag with name space in C#?
<ns:tag1></ns tag1>
<ns:tag2>
<child1></child1>
<child2></child2>
</ns:tag2>

How to read child 1 tag?
I am able to till ns:tag2 but unable to read any further tag.
var child = parentElement.Descendants(ns + "tags").First();
This provides list of child tags, but unable to further read it.
Tried a few things like:
child.Descendants("child1").First().Value
and child.Element("child1") (with all possible sub functions)
etc
Even tried to reload the xml from tag2 in XElement again but that threw invalid xml exception.
but all are throwing null pointer exceptions.
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Solution has been posted.