comparing two XML->objects

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin Blount

    comparing two XML->objects

    I'm getting data from an XML file using this method:

    $name = $xml->user_info->user['name'];
    $nickname = $xml->user_info->user['nickname'];

    &

    $age = $xml->user_info->user['age'];
    $shoe_size = $xml->user_info->user['show_size'];

    I want to compare name & nickname, and age & shoe_size, but I can't
    figure out how, as all 4 are objects.

    Basically I want to know if age show_size or name == nickname.

    How would I do that?

    I tried:
    if ($age $shoesize)
    {
    echo "age is higher";
    }
    else
    {
    echo "shoesize is higher";
    }

    but it ALWAYS comes out as "shoesize is higher", mostly I think
    because I'm comparing objects, not integers. I just can't find out how
    to convert the obj to an int, or compare two like-typed objects.

  • ZeldorBlat

    #2
    Re: comparing two XML->objects

    On Oct 26, 5:48 pm, Kevin Blount <kevin.blo...@g mail.comwrote:
    I'm getting data from an XML file using this method:
    >
    $name = $xml->user_info->user['name'];
    $nickname = $xml->user_info->user['nickname'];
    >
    &
    >
    $age = $xml->user_info->user['age'];
    $shoe_size = $xml->user_info->user['show_size'];
    >
    I want to compare name & nickname, and age & shoe_size, but I can't
    figure out how, as all 4 are objects.
    >
    Basically I want to know if age show_size or name == nickname.
    >
    How would I do that?
    >
    I tried:
    if ($age $shoesize)
    {
    echo "age is higher";}
    >
    else
    {
    echo "shoesize is higher";
    >
    }
    >
    but it ALWAYS comes out as "shoesize is higher", mostly I think
    because I'm comparing objects, not integers. I just can't find out how
    to convert the obj to an int, or compare two like-typed objects.
    Why wouldn't you just do this:

    if($xml->user_info->user['age'] $xml->user_info->user['shoe_size'])

    Also notice that I used 'shoe_size' instead of 'show_size' -- may be
    your typo, or it might not.

    Comment

    Working...