|
Posted by Ian Taylor on 02/21/07 17:37
dcrackel@gmail.com wrote:
> I hope there is a simple solution to this, but I've been unable to
> find it.
>
>
> $dom = new DomDocument();
> $dom->load("test.xml");
>
> $test = $dom->getElementsByTagName("test");
> $test->nodeValue = "<b>test</b>";
> $dom->save("test.xml");
>
>
> I would like the node in the xml file to look like:
> <test><b>test</b></test>
>
> Rather than the encoded version.
> <b>test</b>
>
> What can be done to accomplish this task?
>
> Thank you
> dwain
>
From what I can see, it's not really possible - if it was possible, and
you tried to re-read the resulting xml file back, you would end up with
something like:
....
<test>
<b>
test
</b>
</test>
....
where <b> is a child node of the <test> node, rather than part of the
value of the <test> node.
Therefore, entities like < and > do need to be encoded / decoded
(possible with html_entity_decode()) when dealing with xml.
If, however, you *are* looking to add <b> as a child node of <test>, I'm
sure there are functions to handle that ( probably something like $child
= $test->append_child('b') )
Navigation:
[Reply to this message]
|