slewrate
April 3rd, 2008, 05:41 PM
Hello.
I am able to read XML data from disk into strings. I obviously created these strings manually. Is there a way to achieve this dynamically?
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(message);
XmlNodeList name = xDoc.GetElementsByTagName("myName");
XmlNodeList telephone = xDoc.GetElementsByTagName("myTelephone");
XmlNodeList email = xDoc.GetElementsByTagName("myEmail");
XmlNodeList age = xDoc.GetElementsByTagName("myAge");
XmlNodeList sex = xDoc.GetElementsByTagName("mySex");
mname = name[0].InnerText;
mtel = telephone[0].InnerText;
memail = email[0].InnerText;
mage = age[0].InnerText;
msex = sex[0].InnerText;
Let's say at some point the XML file changes and I want to add a node for first name in the XML file. Is there a way that my C# program could read this first name into a string without me defining it previously?
Any help is appreciated.
I am able to read XML data from disk into strings. I obviously created these strings manually. Is there a way to achieve this dynamically?
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(message);
XmlNodeList name = xDoc.GetElementsByTagName("myName");
XmlNodeList telephone = xDoc.GetElementsByTagName("myTelephone");
XmlNodeList email = xDoc.GetElementsByTagName("myEmail");
XmlNodeList age = xDoc.GetElementsByTagName("myAge");
XmlNodeList sex = xDoc.GetElementsByTagName("mySex");
mname = name[0].InnerText;
mtel = telephone[0].InnerText;
memail = email[0].InnerText;
mage = age[0].InnerText;
msex = sex[0].InnerText;
Let's say at some point the XML file changes and I want to add a node for first name in the XML file. Is there a way that my C# program could read this first name into a string without me defining it previously?
Any help is appreciated.