Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts

    php and xml help

    Hi all.

    ::: SEE EDIT :::

    I can get student's first name doing this,
    but how do I get first, grade and percent?


    example XML
    Code:
    <students> 
    <item> 
    <stuid>17406</stuid> 
    <num>1</num> 
    <first>John</first> 
    <last>Adams</last> 
    <grade>A</grade> 
    <percent>96.1</percent> 
    </item>
    myPHP
    PHP Code:
    $studs $xml->xpath('/engrade/students/item/first');

    foreach(
    $studs AS $student){
    echo 
    $student;

    Thanks for any help.


    EDIT::::::

    got it


    $items = $xml->xpath('/engrade/students/item');

    foreach($items AS $item){

    printf("%s Grade %s %s <br />", $item->first, $item->grade, $item->percent );

    }


    LT
    Last edited by low tech; 07-06-2013 at 08:41 AM.
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.


 

Posting Permissions

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