Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML::LibXML: replaceNode() removes attribute ns prefixes?

Status
Not open for further replies.

thenewa2x

Programmer
Dec 10, 2002
349
0
0
US
Hello,

When I use [tt]XML::LibXML[/tt]'s replaceNode() method on an element, all of the namespace prefixes are removed from the attributes of the element I used to replace.

Example:
Code:
<ext-link xlink:title="My Title" xlink:href="[URL unfurl="true"]http://www.somedomain.com/">http://www.somedomain.com/</ext-link>[/URL]

Becomes:
Code:
<ext-link title="My Title" href="[URL unfurl="true"]http://www.somedomain.com/">http://www.somedomain.com</ext-link>[/URL]

I tried it with [tt]clean_namespaces()[/tt] set to 0 and 1.

Any ideas?
 
I found a fix but I do not know if this is the best way to handle this problem.

1.) Search for all nodes that will use xlink namespace attributes.
2.1.) If the attribute exists without a namespace, create another attribute WITH the namespace and copy over the value.
2.2.) Delete the original value.
3.) Repeat for each node.

If there is better approach, I would like to see it.

 
Code:
2.2.) Delete the original value.

Meant to be:
Code:
2.2.) Delete the original [!]attribute[/!].

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top