Created
September 3, 2014 21:56
-
-
Save pisarukv/47a906332268ea5ac7b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using MonoTouch.Dialog; | |
using System.Xml; | |
namespace testTask | |
{ | |
public class XmlParser | |
{ | |
XmlDocument xml { get; set; } | |
public XmlParser (XmlDocument xml) | |
{ | |
this.xml = xml; | |
} | |
private RootElement startParse(RootElement root, XmlNodeList nodes) | |
{ | |
RootElement temp = root; | |
foreach(XmlNode node in nodes) | |
{ | |
if (node.HasChildNodes ) { | |
temp[0].Add(startParse(new RootElement (node.Name){ new Section (){ } }, node.ChildNodes)); | |
} | |
else { | |
temp[0].Add(new RootElement (node.Name){ new Section (){ new StringElement (node.OuterXml) } }); | |
} | |
} | |
return temp; | |
} | |
public RootElement getRoot(string name) | |
{ | |
RootElement res = new RootElement (name){ new Section (){ } }; | |
startParse (res,xml.ChildNodes); | |
return res; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment