Simple XML Parser based on NSXMLParser +converter to XML file
How To Setup:
insert next code to file “name of you project”_Prefix.pch
1
2
3
|
#import "XMLNode.h"
#import "XMLParser.h"
#import "XMLConvert.h"
|
Create and launching XMLParser.
You will get parsed data ( with XMLNode data type ) in callbackParser: method
1
2
3
4
5
6
7
8
|
NSURL *URLToFile = [NSURL fileURLWithPath :[[NSBundle mainBundle ]
pathForResource :@"source"
ofType :@"xml"]];
XMLParser *parser = [[XMLParser alloc ] init ];
[parser setDelegate :self withAction :@selector(callbackParser :)];
[parser parseXMLFile :URLToFile ];
[parser release ];
|
Converting results of parsing to XML file:
1
|
NSString *content = [XMLConvert convertXMLNode :root ];
|
And additional define methods for working with XMLNode’s:
XMLaddAttribute(node, object, key), XMLgetAttribute(node, key), XMLsetParent(node, parent), XMLaddChild(parent, child), XMLgetChild(parent, child), XMLremoveChild(parent, child), XMLgetChildWithAttribute(parent, childname, object, key)
Good luck!
UPDATE
More easy convert to XML, but in that solution we use custom nodes