Results 1 to 2 of 2

Thread: Pulling data from xml using php

  1. #1
    Join Date
    Nov 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Pulling data from xml using php

    Ok well let me first say thankyou to any help that is provided as well as a sorry if this is completly and utterly easy to implement.

    So here is my problem: I currently have the following xml document
    --------------------------------------------------------------------------
    <?php
    $xmlstr = <<<XML
    <towns>
    <town>
    <name>Swindon</name>
    <news>http://www.swindonadvertiser.co.uk/news/local/rss/</news>
    <weather>http://weather.yahooapis.com/forecastrss?p=UKXX0147&u=f</weather>
    </town>
    <name>Chatanooga</name>
    <news>http://feeds.feedburner.com/Chattanoogancom</news>
    <weather></weather>
    <name>Ocotal</name>
    <news>http://www.topix.com/rss/ni/ocotal</news>
    <weather> http://weather.yahooapis.com/forecastrss?p=MXOA1090&u=c</weather>
    </town>
    <name>Salzgitter</name>
    <news>http://www.prlog.org/de,sn/rss.xml </news>
    <weather> http://weather.yahooapis.com/forecastrss?p=GMXX0119&u=c</weather>
    </town>
    <name>Torun</name>
    <news> http://www.topix.com/rss/pl/torun </news>
    <weather> http://weather.yahooapis.com/forecastrss?p=PLXX0036&u=c</weather>
    </town>
    </towns>
    ?>
    --------------------------------------------------------------------------
    Now the only thing I would very much like to do is pull the name of say the first town using php then place that name into a html page. I assume this is a very simple task but upon googling I just felt that perhaps the solutions did not answer my specific problem.

    Once again thanks for any help provided

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    http://us3.php.net/manual/en/book.simplexml.php

    It's a bit of a read, especially if you're not familiar with object-oriented programming, but it is the easiest way (IMHO) to deal with xml in php. There should be a good number of threads about xml+php on the DD forums, too.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •