如何获得cdata?

时间:2011-11-16 20:23:14

标签: php xml

  

可能重复:
  PHP: How to handle <![CDATA[ with SimpleXMLElement?

我有以下xml

<locale id="us">
    <toFieldLabel><![CDATA[YOUR FRIEND'S NAME]]></toFieldLabel>
</locale>

当我使用php的简单xml解析它时,我得到以下结果。

    $xml = simplexml_load_file("config.xml");

    echo '<pre>';
    print_r($xml);

[locale] => Array
    (
        [0] => SimpleXMLElement Object
            (
                [@attributes] => Array
                    (
                        [id] => us
                    )

                [toFieldLabel] => SimpleXMLElement Object
                    (
                    )
            )
    )

看看'toFieldLabel',它是空的!!

我如何获得价值?!

更新:

完整的xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>


    <locale id="us">
        <toFieldLabel><![CDATA[YOUR FRIEND'S NAME]]></toFieldLabel>
    </locale>

</configuration>

0 个答案:

没有答案