Tuesday, August 5, 2008

c# .Net XML using XmlDataDocument

Quite often, I need to parse files. I noticed that xml file is really easy to use and simple to define the format.
Last week, I send my mate an xml file scheme and he worked on putting data into xml file. I then read the xml
file and get out the data I need.
Here is some example code:

XmlDataDocument xmlDoc = new XmlDataDocument();
XmlNamespaceManager nsMgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsMgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
nsMgr.AddNamespace("def", "http://www.w3.org/2001/XMLSchema");
XmlNodeList nodes = xmlDoc.SelectNodes("/def:xml_DataSet/def:something", nsMgr);
foreach (XmlNode n in nodes)
foreach (XmlAttribute a in n.Attributes)
switch (a.Name)

foreach (XmlNode m in n.ChildNodes)
switch (m.Name)

1 comment:

Aditi Ray said...

TreasureBox is operated by a group of young, passionate, and ambitious people that are working diligently towards the same goal - make your every dollar count, as we believe you deserve something better.
Check out the best
pop up gazebo
sofa bed
shoe rack nz