Re: [xml] namespaces redeclarations



On Tuesday 17 April 2007, Arne Van Theemsche wrote:
Hi

I use the perl interfaces to libxml2

I'm the current maintainer of it. XML::LibXML is not discussed here but on 
perl-xml listserv activestate com 

imagine I parse an xml like

<foo xmlns:ns2=http://www.foo.bar>
  <ns2:bar/>
</foo>

and then i do a createElementNS("http://www.foo.bar","bar2";) and an
appendChild on the "ns2:bar" I will end up in something like

 <foo xmlns:ns2=http://www.foo.bar>
  <ns2:bar><bar2 xmlns="http://www.foo.bar"/></ns2:bar>
</foo>

Which is correct given your code.

this is syntax wise ok, but i would rather end up in something like

 <foo xmlns:ns2=http://www.foo.bar>
  <ns2:bar><ns2:bar2/></ns2:bar>
</foo>

is there a solution to this or am I just making problems for nothing? :)

yes, use createElementNS("http://www.foo.bar","ns2:bar2";);

-- Petr Pajas



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]