11
Answers

Get value from xml file

darma teja

darma teja

10y
896
1
Hi All,
I have a xml file like this:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<information>
<information1 name="region">Asia</information1>
<information1 name="mainlang">ENG</information1>
</information>
<Data>
<dataname lang="Hindi" group="Asia">
test1.xml
</dataname>
<dataname lang="Chinese" group="Asia">
test2.xml
</dataname>
<dataname lang="English" group="US">
test3.xml
</dataname>
<dataname lang="Polish" group="EU">
test4.xml
</dataname>
</Data>


I am trying to get information/information1['mainlang']  == ENG from xml file.

and also 

I would like to get All "lang, group, dataname" from xml file.

I am getting following error "invalid data at the root level. line 1, position the first" for the following code:

             XDocument doc = XDocument.Load(path);
            XElement test = doc.Root;
            var nodeList = doc.SelectNodes("//dataname");


Advance thanks,
Darma
Answers (11)
Next Recommended Forum