[xml] XPath "//namespace::*" and xml: weirdness
- From: Jason Viers <lists beanalby net>
- To: xml gnome org
- Subject: [xml] XPath "//namespace::*" and xml: weirdness
- Date: Tue, 14 Mar 2006 14:04:08 -0500
Wondering if someone could shed some light on exactly what libxml2 is
doing here. I have the following xml file:
<root><node/><node/></root>
I run the following code on it:
obj = xmlXPathEval("//namespace::*", xpath);
set = obj->nodesetval;
for(i=0;i<set->nodeNr;i++)
{
xmlNsPtr ns = (xmlNsPtr)set->nodeTab[i];
printf("Found ns (%i) %s=%s\n", ns, ns->prefix, ns->href);
}
Gives the following output:
Found ns (3303224) xml=http://www.w3.org/XML/1998/namespace
Found ns (3303320) xml=http://www.w3.org/XML/1998/namespace
Found ns (3303416) xml=http://www.w3.org/XML/1998/namespace
-------------------
I understand that the "xml" namespace is magical, doesn't need declared,
only for lang/space, etc. Before/after running this XPath I can't find
any references to these ns structures anywhere in the document. I've
realized that actually using xml:space in a parsed document creates a
"global"(-ish) "xml" ns set up in the doc's/node's "oldNS" field, but
that doesn't help with these.
What are these ns structures returned by the XPath? Archives didn't
seem to have anything related, and looking through the xpath.c source
made my brain melt. Are these alloc'd that need to be freed? Is there
any part of the tree that references these? Is there a proper workflow
for adding a new "xml:space" to a newly created document?
Thanks
Jason
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]