Something confuses me here:
The NSXMLParser method has a namespaceURI attribute:
- (void)parser:(NSXMLParser *)parser
didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName
From the documentation I couldn’t figure out what they mean by “namespace”. Can someone explain with an example what a namespace is in a XML and why I would want that?
Edit: Yep, I noticed wikipedia. But it’s confusing, again. What sense does it make to put one single namespace declaration at the top of the XML file like
xmlns:xhtml="http://www.w3.org/1999/xhtml"
?? Again, that makes just zero sense. Wikipedia has no useful example either to get it, why I would really want namespaces and -more importantly- how this looks in an XML file. They say it’s for resolving ambiguity of multiple same-named elements like ID, but there’s no example how multiple namespaces would resolve that.
XML namespaces work like namespaces everywhere else.
They provide a means to uniquely distinguish equally named elements or attributes. This is done by declaring a namespace URI, and optionally attaching a prefix to the node name. This prefix is (optionally) defined along with the namespace declaration.
Namespaces are strictly scoped. They are available to the node and its descendants only. To have a namespace available in the entire XML document, it must be declared at the top level element (document element).
In your case, on the example or
<prefix:child />: