How can I extract data of an external XML to PHP?

How to extract table data from article with PHP?

  • I have CMS website, maked in Joomla. There are articles about traveling and I've dates in there. Dates are in tables on each page. Question is how to extract dates like array from table inherit in article and copy them in dropdown box in contact form? This is exampe, tr> <td>08.03.2012. </td> <td>22.03.2012.</td> </tr> How to extract those dates and put in dropdown box in contact form? Thank you!

  • Answer:

    Check out PHP's DOMXPath class. It will parse XML or HTML strings and extract any elements that match the path you specify. For your example, a path of "//tr/td" would capture an array of td elements that are within a tr element. Of course you should use some qualifiers to capture only the td cells you are interested in. Something like the following might work. "//table[@id='tableID']/tr/td" Take a little time to review the concept of XPATH and how to integrate it into PHP and you should be good to go.

darko k at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

javascript assign an id to each td you want to collect the data from <td id='date1'>22.03.2012.</td> if your looking to use php you would need to post the data from this page to the next. <body onload='document.myformid.submit();> echo "<form name='myformid' action=' mynextpage.com' >"; for($i=0;$i>=$countarray-1;$i++) { echo "<input <button= 'hidden' id='$i' type= 'hidden' value='' />" } echo </form> <script type javascript> for($i=0;$i>=$countarray-1;$i++) { document.forms[0]elimint[$i].value = document.getdocumentby('date[$i]').inner… } </script>

Mark O

Related Q & A:

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.