SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2006
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Show only part of XML

    I have XML like that:

    Code XML:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <note>
     
    <Table>
    <ID>156</ID>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don't forget me this weekend!</body>
    </Table>
     
    <Table>
    <ID>536</ID>
    <from>Peter</from>
    <heading>Reminder</heading>
    <body>Don't forget football match this weekend!</body>
    </Table>
     
    <Table>
    <ID>613</ID>
    <from>Kevin</from>
    <heading>Reminder</heading>
    <body>Don't forget for chess this weekend!</body>
    </Table>
     
    </note>

    I just want to display particular data from <Table> to </Table>" where for example ID is equal to 536.

    How should I do that?
    Any idea?
    Last edited by drag; May 19, 2009 at 06:58.

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have php5 you can use simpleXML:

    PHP Code:
    $note simplexml_load_file('member.xml');
    $tables $note->Table;
    foreach (
    $tables as $table) {
      if (
    $table->ID == 536) {
        echo 
    $table->from;
        echo 
    $table->heading;
        echo 
    $table->body;
      } 



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
  •