-
xml help[RESOLVED]
been trying and going insane
I have written an xml doc like he following:
<Main>
<Something1>valueHere</Something1>
<Something2>valueHere</Something2>
</Main>
but how do I read the first element (Something1) and then the text inbetween? (valueHere)
this is what I have:
Code:
XmlTextReader tr = new XmlTextReader(path);
while(tr.Read())
{
if (tr.NodeType == XmlNodeType.Text)
{
tr.ReadString();
if (tr.Name.Equals("Something1"))
{
//value/name
}
..
..
}
}
but it only gets the Name (Somethingx) but not the inner value.
any ideas?
-
Re: xml help[RESOLVED]
post your solution if you don't mind, in case someone else is looking for the same thing :thumb:
-
Re: xml help[RESOLVED]
sure
Code:
XmlTextReader reader = new XmlTextReader(@pathToXmlFile);
while (reader.Read())
{
reader.MoveToContent();
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name.Equals("TagNameToLookFor"))
{
reader.ReadStartElement(reader.LocalName);
string theValueOfThisTag = reader.Value;
}
//..
//..
}
}