How can I add root element to DDXMLDocument

1,448 views
Skip to first unread message

amadamala

unread,
Feb 1, 2010, 2:46:02 AM2/1/10
to KissXML
Hello,

Thanks for the nice framework.

I'm trying to use kissXML framework. I'm using NSXML's documentation
as reference.

I wanted to write following piece of code[apple's NSXML] using kissXML
NSXMLElement *root =
(NSXMLElement *)[NSXMLNode elementWithName:@"addresses"];
NSXMLDocument *xmlDoc = [[NSXMLDocument alloc]
initWithRootElement:root];

I tried to convert the above sample program. But I'm not able to find
equivalent method for initWithRootElement.

Is there any equivalent way to achieve the same using kissXML
framework.

thanks in advance.
-- Anil

Nathan de Vries

unread,
Feb 1, 2010, 10:32:13 PM2/1/10
to kis...@googlegroups.com
Hi Anil,

Not sure if you can initialise a DDXMLDocument using a DDXMLElement, but you can do it like this:

DDXMLDocument* document = [[[DDXMLDocument alloc] initWithXMLString:@"<addresses/>" options:0 error:nil] autorelease];
DDXMLElement* root = [document rootElement];
[root addChild:[DDXMLNode elementWithName:@"address" stringValue:@"Some Address"]];

This will give you:

<addresses>
<address>Some Address</address>
</addresses>

Hope that helps.


Cheers,

Nathan

Robbie Hanson

unread,
Feb 2, 2010, 3:21:25 AM2/2/10
to kis...@googlegroups.com
I added a new issue for this:
http://code.google.com/p/kissxml/issues/detail?id=29

-Robbie Hanson

> --
> You received this message because you are subscribed to the Google Groups "KissXML" group.
> To post to this group, send email to kis...@googlegroups.com.
> To unsubscribe from this group, send email to kissxml+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/kissxml?hl=en.
>

amadamala

unread,
Feb 2, 2010, 3:33:56 AM2/2/10
to KissXML
Hi Nathan
Thanks or your reply. I will try your solution. It is what I needed
for now.

-- Anil

Reply all
Reply to author
Forward
0 new messages