Re: KissXML and attribute namespaces

250 views
Skip to first unread message
Message has been deleted

Robbie Hanson

unread,
Jun 17, 2009, 6:07:41 PM6/17/09
to kis...@googlegroups.com
I whipped up some code to test this:

NSMutableString *mStr = [NSMutableString stringWithCapacity:25];
[mStr appendString:@"<foo:root xmlns:foo='http://foo.com/' xmlns:bar='http://bar.com/'>"];
[mStr appendString:@"  <foo:a atta='a' foo:attb='b' bar:attc='c' />"];
[mStr appendString:@"</foo:root>"];


NSXMLDocument *nsDoc = [[NSXMLDocument alloc] initWithXMLString:mStr options:0 error:nil];


NSXMLElement *nsa = [[[nsDoc rootElement] elementsForName:@"foo:a"] objectAtIndex:0];
NSLog(@"nsa: %@", [nsa attributes]);


DDXMLDocument *ddDoc = [[DDXMLDocument alloc] initWithXMLString:mStr options:0 error:nil];


DDXMLElement *dda = [[[ddDoc rootElement] elementsForName:@"foo:a"] objectAtIndex:0];
NSLog(@"dda: %@", [dda attributes]);

And here is the output:

2009-06-17 17:07:00.435 KissXML[574:10b] nsa: (
    atta="a",
    foo:attb="b",
    bar:attc="c"
)
2009-06-17 17:07:00.436 KissXML[574:10b] dda: (
    atta="a",
    foo:attb="b",
    bar:attc="c"
)
2009-06-17 17:07:00.437 KissXML[574:10b] Testing took 0.002815 seconds

How are you trying to access the attributes?

-Robbie Hanson
-Deusty Designs




On Jun 14, 2009, at 10:58 PM, Tobias wrote:


Hi all,

I am having troubles accessing attributes with namespaces...

A simple example would be:

<foo:root xmlns:foo="http://foo.com/" xmlns:bar="http://bar.com/">
 <foo:a atta="a" foo:attb="b" bar:attc="c" />
</foo:root>

If I have a DDXMLElement that is representing <foo:a ...>, it only has
one attribute: atta. I can't access the other attributes... Is there a
way to accomplish this?

Also: Is there a better way of debugging DDXML*-Objects? I cannot
access the attributes etc. like on other objects...

Cheers,

Tobias



Reply all
Reply to author
Forward
0 new messages