I have a NSString that is holding xml.
sample: <Documents>
<Document>Document1</Document>
<Document>Document2</Document>
</Documents>
What I am trying to do is parse this xml using the NSXMLParser. I see lots of examples using the initWithContentsOfURL and initWithData.
NSXMLParser *pXML = [[NSXMLParser alloc] initWithData:yourXML];
[pXML setDelegate:self];
[pXML parse];
NSXMLParser *pXML = [[NSXMLParser alloc] initWithContentsOfURL:yourURL];
[pXML setDelegate:self];
[pXML parse];
When using the initWithData the parameter must be of type NSData. Is there any way to convert the NSString to NSData so it can be initialized into the parser? Or is there another way I should perform this?
Thanks in advance.
sample: <Documents>
<Document>Document1</Document>
<Document>Document2</Document>
</Documents>
What I am trying to do is parse this xml using the NSXMLParser. I see lots of examples using the initWithContentsOfURL and initWithData.
NSXMLParser *pXML = [[NSXMLParser alloc] initWithData:yourXML];
[pXML setDelegate:self];
[pXML parse];
NSXMLParser *pXML = [[NSXMLParser alloc] initWithContentsOfURL:yourURL];
[pXML setDelegate:self];
[pXML parse];
When using the initWithData the parameter must be of type NSData. Is there any way to convert the NSString to NSData so it can be initialized into the parser? Or is there another way I should perform this?
Thanks in advance.