Log in

View Full Version : Resolved XML namespaces reading problem in PHP



Aniruddhya Hazra
08-21-2011, 03:01 PM
Hi,

Can't read namespaces fields "issuu" to the following XML by PHP -

Please help me.Thanks.

-----------XML code-------------
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:issuu="http://www.issuu.com/opensearchrss/1.0/" xmlns:media="http://search.yahoo.com/mrss/" version="2.0" issuu:id="6cf1df7d-a43c-47f5-a06c-b2bbb0a5c304" issuu:type="folder">
<channel>
<title>
contractor
</title>
<description>
georgia contractor
</description>
<link>
http://issuu.com
</link>
<lastBuildDate>
Sat, 20 Aug 2011 19:23:42 GMT
</lastBuildDate>
<atom:link href="http://feed.issuu.com/folder/6cf1df7d-a43c-47f5-a06c-b2bbb0a5c304/rss20.xml" rel="self" type="application/rss+xml"/>
<issuu:fields>
<issuu:field name="username" value="a4inc"/>
<issuu:field name="folderId" value="6cf1df7d-a43c-47f5-a06c-b2bbb0a5c304"/>
<issuu:field name="items" value="2"/>
</issuu:fields>
<item>
<guid>
http://issuu.com/a4inc/docs/contractormagazine_august2011/1
</guid>
<title>
The Georgia Contractor - July/August
</title>
<description>
July/August
</description>
<link>
http://issuu.com/a4inc/docs/contractormagazine_august2011/1
</link>
<pubDate>
Fri, 19 Aug 2011 17:50:51 GMT
</pubDate>
<content:encoded>
Webqueue Solutions
</content:encoded>
<media:content url="http://image.issuu.com/110729155513-54ef1ffe5df44ff88b030064d123f083/jpg/page_1_thumb_large.jpg"/>
<media:thumbnail url="http://image.issuu.com/110729155513-54ef1ffe5df44ff88b030064d123f083/jpg/page_1_thumb_medium.jpg"/>
<issuu:page number="1"/>
<issuu:fields>
<issuu:field name="title" value="The Georgia Contractor - July/August"/>
<issuu:field name="type" value="bookmark"/>
<issuu:field name="documentId" value="110729155513-54ef1ffe5df44ff88b030064d123f083"/>
<issuu:field name="name" value="contractormagazine_august2011"/>
<issuu:field name="user" value="a4inc"/>
<issuu:field name="description" value="July/August"/>
<issuu:field name="created" value="2011-08-19T17:50:51.000Z"/>
</issuu:fields>
</item>
<item>
<guid>
http://issuu.com/a4inc/docs/contractor_mayjune20111/1
</guid>
<title>
contractor_mayjune2011
</title>
<description>
The Georgia THE VOICE OF THE CONSTRUCTION INDUSTRY OF GEORGIA May | June 2011 Volume 7, Issue 3
</description>
<link>
http://issuu.com/a4inc/docs/contractor_mayjune20111/1
</link>
<pubDate>
Fri, 19 Aug 2011 17:50:25 GMT
</pubDate>
<content:encoded>
Webqueue Solutions
</content:encoded>
<media:content url="http://image.issuu.com/110804204444-968f0f5d3f1b4b999cb4ffde7948ba32/jpg/page_1_thumb_large.jpg"/>
<media:thumbnail url="http://image.issuu.com/110804204444-968f0f5d3f1b4b999cb4ffde7948ba32/jpg/page_1_thumb_medium.jpg"/>
<issuu:page number="1"/>
<issuu:fields>
<issuu:field name="title" value="contractor_mayjune2011"/>
<issuu:field name="type" value="bookmark"/>
<issuu:field name="documentId" value="110804204444-968f0f5d3f1b4b999cb4ffde7948ba32"/>
<issuu:field name="name" value="contractor_mayjune20111"/>
<issuu:field name="user" value="a4inc"/>
<issuu:field name="description" value="The Georgia THE VOICE OF THE CONSTRUCTION INDUSTRY OF GEORGIA May | June 2011 Volume 7, Issue 3"/>
<issuu:field name="created" value="2011-08-19T17:50:25.000Z"/>
</issuu:fields>
</item>
</channel>
</rss>
-------------------end XML code-----------------------

Aniruddhya Hazra
08-21-2011, 03:04 PM
Hi,

Here is the original feeds source
http://feed.issuu.com/folder/6cf1df7d-a43c-47f5-a06c-b2bbb0a5c304/rss20.xml

Thanks.

traq
08-21-2011, 08:01 PM
Your question is unclear.
Please provide more information, and be as specific as possible.
What do you want to accomplish? What have you already tried? What problems did you encounter?
Also, please be sure that you have included all relevant code and/or a link to the page in question.

you don't offer any php code, or even mention what you're using to try to read the xml. DOMDocument? SimpleXML? please give a better explanation of your problem.

Aniruddhya Hazra
08-22-2011, 12:04 PM
I have sorted it out. It's working now. Bellow is the code. I wanted to read the "issuu" fields from the RSS feed I pasted to my first post. Thanks to all.

<?php
$dom=new DOMDocument();
$dom->load("rss20.xml");
$xpath = new DomXPath($dom);
$xpath->registerNamespace('issuu', "http://www.issuu.com/opensearchrss/1.0/");
$query = '/rss/channel/item/issuu:fields/issuu:field[@name="documentId"]/@value';
$results = $xpath->query($query, $dom);
foreach($results as $result)
{
echo $result->nodeValue.'1<br/>';
}
?>

JShor
08-22-2011, 03:20 PM
Since this issue is now resolved, please mark the thread as Resolved to communicate to other members that this is no longer pending.

Aniruddhya Hazra
08-22-2011, 03:24 PM
From where to mark it? I do not find option. Please let me know.

Thanks.

traq
08-22-2011, 08:05 PM
click [ edit ] on your first post, then click [go advanced].
next to the post tile there is a drop-down box labeled "Prefix:"; select the option that says "Resolved".

Aniruddhya Hazra
08-23-2011, 08:32 AM
Ok I have done it. Thank you.