Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2006
    UK - Wales

    XPath - getting tags

    hey ppl (im in a good mood for a change ),

    after a previous attempt at making a news script with php and xml i decided to learn php and xml first (good idea huh?).

    anyway - using xpath to get certain data in an xml file you use:

    print $title->textContent . "\n"; (or similar)

    to display the content of each tag.

    is there a way to display the name of the tags as well - like (and i know this doesn't work):

    print $title->valueTag . "\n"; or textTag or something

    any help... Thanks!
    Last edited by spasticus; 10-27-2006 at 07:24 PM.

  2. #2
    Join Date
    Oct 2006
    UK - Wales
    as ive used up my edit i should add:


    $value = "a title of one of the posts";

    $dom = new DomDocument();

    $xp = new domxpath($dom);
    $titles = $xp->query("/ARCHIVE/POST[TITLE='". $value ."']");

    foreach ($titles as $title) {
    print $title->textContent;


    theres my whole code - the problem is now.. i want to get each tags value so i can display it where i want on the page (in a table). thing is i cant get the name of any nodes under POST which is what i need.

    the code above gives me everything i need but not how i need it. if anyone knows of a way or where to go Id appreciate you posting it.


Posting Permissions

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