How can I parse a complex XML with PHP and CDATA?

Let’s learn how can I parse a complex XML with PHP and CDATA. The most accurate or helpful solution is served by Stack Overflow.

There are ten answers to this question.

Best solution

PHP XML Cannot parse the CDATA

I am parsing into PHP an RSS feed from the national data buoy center. I am not able to parse in the description which is tagged as CDATA. The end goal is to have the description items variables such as Location, Wind Direction, Wind Speed, etc.. I am unsure how to break this out and omit the tags. Here is a snippet of the feed: <item> <pubDate>Thu, 08 Sep 2011 17:59:39 UT</pubDate> <title>Station SFXC1 - SAN FRANCISCO BAY RESERVE, CA</title> <description><...

Answer:

Rewrote my solution to actually be correct: $feed_url = "http://www.ndbc.noaa.gov/rss/ndbc_obs...

Read more

matt colley at Stack Overflow Mark as irrelevant Undo

Other solutions

How Can I fetch and parse XML from an other website using PHP?

UPDATE: I have changed this question a bit from what I learned and restructured it here: How do I parse JSON with PHP? __________________ Previously: I am creating a website in php. I need to add a search that uses an api from another website. I know...

Answer:

AJAX is a client-side technique, you cannot do it with PHP. However, you can fetch an URL using file...

Read more

Baptiste Fontaine at Quora Mark as irrelevant Undo

What is the best way to parse XML (RSS) in PHP?

I've not coded for about 5 years and I'm trying to get back into things to help out but it's taking some time. I'd like to parse a load of RSS feeds and output to HTML using PHP.

Answer:

Use SimpleXML (http://php.net/manual/en/book.si...), which has been part of Core PHP since PHP 5.0....

Read more

David Powers at Quora Mark as irrelevant Undo

Accessing a parent attribute in XML with PHP - sample code porovided

I am having a heck of a time getting at a attribute of a parent in my XML from PHP. here is a sample of the XML: ************************************* SAMPLE XML CODE START ************************************* <results first="1" last...

Answer:

Hello pcormie-ga Thank-you for your question. I have been able to troubleshoot your question for you...

Read more

pcormie-ga at Google Answers Mark as irrelevant Undo

I do declare! But my XML doesn't.

We are moving our sites from a WAMP to a LAMP and one of the XML parser classes has gone all haywire. Eeep. I love that I have another developer on my team now, but unfortunately, that means I don't know every piece of code on our sites. Kid Wonder created...

Answer:

Smart quotes?

Read more

foxydot at Ask.Metafilter.Com Mark as irrelevant Undo

XML and & Symbol in ASP

I'm having problems with an XML feed. I use the below ASP code to download the feed: Set objSrvHTTP = Server.CreateObject ("MSXML2.ServerXMLHTTP") objSrvHTTP.open "GET","http://www.website.com?getfeed=1", false objSrvHTTP...

Answer:

As the ampersand is used to signify the encoding of an entity (ie escaped character) it needs to be...

Read more

xemion-ga at Google Answers Mark as irrelevant Undo

How do I parse JSON with PHP?

I am trying to get data from an external website using an api. I am trying to use simplexml and am running into a few problems. Edit and Update: So Everyone has told me to try json instead of xml. I switched to json and I have this so far: $response...

Answer:

According to your JSON code, the following code should work: $response = file_get_contents($uri); ...

Read more

Baptiste Fontaine at Quora Mark as irrelevant Undo

Answer:

You will use an xml parser like simple xml. If you will focus on timeout/connection time out in curl...

Read more

wiki.answers.com Mark as irrelevant Undo

Answer:

It depends on what you need, but here's a snippet of some PHP 5.3 code I wrote that parses a weather...

Read more

John David Anderson at Quora Mark as irrelevant Undo

How can i update the innerHTML of a div when a remote xml file is updated?

I have this remote XML file: http://api.own3d.tv/liveCheck.php?live_id=14760 When one of those values gets updated, I want to use some php or javascript or asp code to parse it and update the innerHTML of a div on my site with that value. ALSO i would...

Answer:

read up on ajax -- asynchronous requests made by polling a server for results.

Read more

Monster at Yahoo! Answers Mark as irrelevant Undo

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.