Jump to content

Modify a namespace


Luxuguy

Recommended Posts

Hi,I have created a root node like this:<root></root>I also create another node like this:<child></child>Now I want to write a method that:+ insert the Child node into root+ insert a namespace "ts" in front of the childSo it will look like this:<root><ts:child></ts:child><root>Inserting the child node into root node is simple ( I know how to do it ), but I have no clue how to insert "ts" in front of child.Can anyone help me ?Thanks a lot,Luxuguy

Link to comment
Share on other sites

What language are we talking about?In PHP, it's as simple as using createElementNS() and knowing the actual namespace URI behind the "ts" prefix. eg.

$dom->documentElement->appendChild($dom->createElementNS('http://example.com/myNamespace', 'child', 'Contents of the child element (optional)'));

Assuming the namespace URI is "http://example.com/myNamespace" of course.

Link to comment
Share on other sites

Well... how do you insert a non-namespaced element? Is it again with DOM (i.e. with an appendChild() and createElement() duo)? If so, the solution is again to use createElementNS() instead.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...