copying nodes from xpath results to a domxml

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mcmcom
Forum Newbie
Posts: 14
Joined: Thu Jan 31, 2008 7:23 am

copying nodes from xpath results to a domxml

Post by mcmcom »

hi all,
i am doing a search with xpath and returning nodesets that match a string.
from there i would like to copy these node sets into another domxml element in memory.

so example my xml looks like this
<block>
<var1>blah</var1>
....
<var55>blah</var55>
</block>
<block>
<var1>blah blah</var1>
...
<var55>blah 2</var55>
</block>

so when i search for blah and get back 2 node sets i would like (ideally) to copy everything in side the <block> tags and put them in a new xml dom element i created. However i can't seem hoow to figure it out.

i would like to get all the child nodes of <block> without having to create them manually (as they may change)
any one have a sample code i can try? i already have the xpath working fine and it returns these node sets, i just dont know how to copy all child nodes to a new element. i can create a new element tag with the proper name, but i cannot seem to add the data into the elements.
thanks in advance,
mcm
Post Reply