Skip to content

Instantly share code, notes, and snippets.

@pisarukv
Created September 3, 2014 21:56
Show Gist options
  • Save pisarukv/47a906332268ea5ac7b1 to your computer and use it in GitHub Desktop.
Save pisarukv/47a906332268ea5ac7b1 to your computer and use it in GitHub Desktop.
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