[ Start > PikeModules > Module > Public.Parser.XML2 ] [ Edit this Page | Viewing Version 1 ]

Namespaces in XML2

Public.Parser.XML2 handles namespaces a bit differently than Parser.XML. This brief overview of the process should help explain things a little better.

get_attributes() will return all attributes without their namespace attached. In cases where there are two attributes with the same "local" name, the first defined attribute will be returned.

For example, in this contrived xml snippet:

xmlns:soap="" nonsatt="foo"
soap:collision="1" collision="2">

We get the following result:

> n->get_attributes();
(1) Result: ([ /* 3 elements */
              "collision": "1",
              "encodingStyle": "",
              "nonsatt": "foo"

get_ns_attributes(string ns_uri) should return all attributes with a given namespace URI.

For example, in the previous document,


(2) Result: ([ /* 2 elements */ "collision": "1", "encodingStyle": "" ])

n->get_nss() should return a list of all namespace (prefix:uri) pairs defined for the node. The default namespace will have an index of "".

n->get_ns() should return the default namespace for the node.

Powered by PikeWiki2 | Copyright © 2004 - 2009 | Pike is a trademark of Department of Computer and Information Science, Linköping University