测试.xml
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"
    xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:wp="http://wordpress.org/export/1.2/"
>
    <item>
        <title>Hello world!</title>
        <link>http://localhost/wordpress/?p=1</link>
        <category><![CDATA[Uncategorized]]></category>
        <HEADLINE><![CDATA[Does Sleep Apnea Offer Some Protection During Heart Attack?]]></HEADLINE>
    </item>
</rss>
我用那个代码读取xml文件
    <?php
      if (file_exists('test.xml')) {
        $xml = simplexml_load_file('test.xml');
          echo "<pre>";
          print_r($xml);
          echo "</pre>";
      } else {
         exit('Failed to open test.xml.');
         }
     ?>
输出
      SimpleXMLElement Object
 (
 [@attributes] => Array
    (
        [version] => 2.0
    )
[item] => SimpleXMLElement Object
    (
        [title] => Hello world!
        [link] => http://localhost/wordpress/?p=1
        [category] => SimpleXMLElement Object
            (
            )
        [HEADLINE] => SimpleXMLElement Object
            (
            )
    )
 )
但我对 xml 中的那些标签有疑问
        <category><![CDATA[Uncategorized]]></category>
    <HEADLINE><![CDATA[Does Sleep Apnea Offer Some Protection During Heart Attack?]]></HEADLINE>
 to read data bcoz of it <![CDATA[]] in category and HEADLINE
我需要输出
        SimpleXMLElement Object
   (
 [@attributes] => Array
    (
        [version] => 2.0
    )
[item] => SimpleXMLElement Object
    (
        [title] => Hello world!
        [link] => http://localhost/wordpress/?p=1
        [category] => Uncategorized
        [HEADLINE] => Does Sleep Apnea Offer Some Protection During Heart Attack?
    )
 )