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();
xmlDoc.Load(strFile);
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)
{
}
}
}



4 comments:

Anonymous said...

Have you been thinking about the power sources and the tiles whom use blocks I wanted to thank you for this great read!! I definitely enjoyed every little bit of it and I have you bookmarked to check out the new stuff you post. java training in jalandhar

Unknown said...

a pride for me to be able to discuss on a quality website because I just learned to make an article on
cara menggugurkan kandungan

Unknown said...

REALLY VERY EXCELLENT INFORMATION. I AM VERY GLAD TO SEE YOUR BLOG FOR THIS INFORMATION. THANKS FOR SHARING. KEEP UPDATING.

Best Digital Transformation Services | DM Services | Austere Technologies

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