使用simplexml_load_string后仍然保留标签[重复]

This question already has an answer here:

I am using simplexml_load_string for XML packets. In my scenario, the XML string I want to convert is known as k. My problem, however, is that when I use k, tags still remain that weren't parsed (<k>, <\k>).

For example, I use $x->k, and I get back <k>DATA I WANT HERE<\EK>. How do I get rid of these?

What the code does: It connects to a game and logs in.

</div>

Use InnerNode to get the value without the tags:

$x->k->InnerNode

You can also do a typecast:

(string)$x->k

I tried this and seem to be getting the string.

<?php
$str = "<msg t='sys'><body action='rndK' r='-1'><k>qH~e9Gmt</k></body></msg>";

$xml = simplexml_load_string( $str );
echo $xml->body->k; // gives 'qH~e9Gmt'
?>