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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 20, 2012, 12:38 AM EST
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.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 19, 2012, 11:40 PM EST
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.
jit sun40 reputationPosted Jan 20, 2012, 12:07 AM EST
thx.
i need name as output only.
Mukesh KumarRank #615 · 3.9K reputationPosted Jan 20, 2012, 12:09 AM EST
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;