php - SimpleXML: adding "xmlns:wp" attribute adds only "wp", why? -
im trying create wxr file scratch (wordpress extended rss).
my code based on xml/wxr file generated wordpress , starts this:
<?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/" >
i started this:
$newxml = new simplexmlelement("<rss></rss>"); $newxml->addattribute('version', '2.0'); $newxml->addattribute('xmlns:excerpt', 'http://wordpress.org/export/1.2/excerpt/'); $newxml->addattribute('xmlns:content', 'http://purl.org/rss/1.0/modules/content/'); $newxml->addattribute('xmlns:wfw', 'http://wellformedweb.org/commentapi/'); $newxml->addattribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $newxml->addattribute('xmlns:wp', 'http://wordpress.org/export/1.2/');
after im printing xml this:
echo htmlspecialchars($newxml->asxml());
im getting xml this:
<?xml version="1.0"?> <rss version="2.0" excerpt="http://wordpress.org/export/1.2/excerpt/" content="http://purl.org/rss/1.0/modules/content/" wfw="http://wellformedweb.org/commentapi/" dc="http://purl.org/dc/elements/1.1/" wp="http://wordpress.org/export/1.2/"> <channel/> </rss>
(i added line breaks improve readability).
how can forcefulness total attributes, "xmlns:excerpt" instead of "excerpt"?
the part before colon called "namespace" , needs specified separately. addattribute
3rd parameter:
$newxml->addattribute ('excerpt', 'http://wordpress.org/export/1.2/excerpt/', 'xmlns');
php xml wordpress simplexml
No comments:
Post a Comment