Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Need help....

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

    Default

    You're using (parenthesis) instead of [square brackets] for your indices. Try $authors->item[0]->nodeValue (et al.) instead.

  2. #12
    Join Date
    May 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    man... another fatal error : Fatal error: Cannot instantiate non-existent class: domdocument in /~/www/transparent.agilityhoster.com/test.php on line 2

    wait. imma check...
    <?php
    $doc = new DOMDocument();
    $doc->load( 'abc.xml' );

    $books = $doc->getElementsByTagName( "book" );
    foreach( $books as $book )
    {
    $authors = $book->getElementsByTagName( "author" );
    $author = $authors->item[0]->nodeValue;

    $publishers = $book->getElementsByTagName( "publisher" );
    $publisher = $publishers->item[0]->nodeValue;

    $titles = $book->getElementsByTagName( "title" );
    $title = $titles->item[0]->nodeValue;

    echo "$title - $author - $publisher\n";
    }
    ?>

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

    Default

    where are you testing this? does your host support php5 and libxml? DOMdocument can also be disabled deliberately by your host; check with them to see if it is enabled.

  4. #14
    Join Date
    May 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry for the late reply, they only have PHP 4.2.3 so I went to another free web hosting site

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

    Default

    that explains it.

    you might look into the simpleXML class as well; some aspects are much easier.

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
  •