SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    web daemon jorasmi's Avatar
    Join Date
    Nov 2001
    Location
    Philippines
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help Pull Data From XML

    How do i extract or pull the data from an xml document and put it on a webpage. I provided below a simple xml document that I want to pull data from.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don't forget me this weekend!</body>
    </note>

    the xml document is save as note.xml

    thanks

  2. #2
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    420
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    didnt you get that xml from www.w3schools.com ?

    if you read the rest of their tutorial on xml and xsl you should be able to figure it out, I did.
    Wavelan

  3. #3
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    420
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use a data island
    Wavelan

  4. #4
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats what I was gonna say

    here you go
    Mike
    It's not who I am underneath, but what I do that defines me.

  5. #5
    web daemon jorasmi's Avatar
    Join Date
    Nov 2001
    Location
    Philippines
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what i mean is how do i pull xml using php

  6. #6
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    420
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh sorry I dont know much about PHP yet
    Wavelan

  7. #7
    SitePoint Member
    Join Date
    May 2002
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check out this article

  8. #8
    SitePoint Member
    Join Date
    May 2002
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    woops

    That wasn't the article I meant to post, and I don't know where I read the one I did... hmmm.. Well I'll give you an example. This is an example translating the XBEL (an XML based bookmark format) file salmo.xbel using the XSLT stylesheet xbel-1.0-2.xsl.

    PHP Code:
    $xbel_path "/path/to/salmo.xbel";
    $xslt_path "/path/to/xbel-1.0-2.xsl";

    // Create an XSLT processor
    $xsltproc xslt_create();

    // Perform the transformation
    $html xslt_process($xsltproc$xbel_path$xslt_path);

    // Detect errors
    if (!$html) die('XSLT processing error: '.xslt_error($xsltproc));

    // Destroy the XSLT processor
    xslt_free($xsltproc);

    // Output the resulting HTML
    echo $html
    I'm using the Sablotron XSLT functions for PHP by the way. You can see if you've got that installed by using this:
    PHP Code:
    if (function_exists("xslt_create")){
      echo 
    "Hells yeah!";
    } else {
      echo 
    "Son of a...!";

    Or you can look through the output of phpinfo(). If you need help installing Sablotron on Linux let me know.

    Enjoy!


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
  •