test.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?
)
)