I have a tag in my xml like this
i want to retrive the NAME VALE in my textbox. the result should be German.
how can i write the code in c#
thanks in advance
jitendra
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jan 20, 2012, 5:38 AM
you can try this,
string str1 = @" ";
StringReader theReader1 = new StringReader(str1);
XmlTextReader reader = new XmlTextReader(theReader1);
XmlDocument doc = new XmlDocument();
doc.Load(reader);
var testReader = doc.FirstChild.ChildNodes;
foreach (var mychild in testReader)
{
var childatt = ((XmlElement)mychild);
var name = childatt.Attributes["NAME"].Value;
}
hope this help.
Mukesh KumarPosted Jan 20, 2012, 5:09 AM
Try this,
XmlTextReader reader = new XmlTextReader(@"D:\XMLFile1.xml");
XmlDocument doc = new XmlDocument();
doc.Load(reader);
XmlElement test = (XmlElement)doc.SelectSingleNode("/SRC_LNG");
string ID = test.Attributes["ID"].Value;
string NAME = test.Attributes["NAME"].Value;
string TS = test.Attributes["TS"].Value;
jit sunPosted Jan 20, 2012, 5:07 AM
thx.
i need name as output only.
Jignesh TrivediPosted Jan 20, 2012, 4:40 AM
try this.
string str = @"
StringReader theReader = new StringReader(str);
DataSet theDataSet = new DataSet();
theDataSet.ReadXml(theReader);
in this dataset you will get three column ID,Name and TS
hope this help.