data inside XML string

Discussion in 'Programming' started by roice, Apr 7, 2010.

  1. #1
    Hello,
    The following link will give you the number of the Inbound link to some url:
    http://search.yahooapis.com/SiteExplore ... output=xml

    In the top you can find "totalResultsAvailable=14370725"
    how can I get the number into varibale?

    I tried this:

    <?PHP
    $resp = file_get_contents("http://search.yahooapis.com/SiteExplorerService/V1/inlinkData?appid=YahooDemo&query=http://www.cnn.com&omit_inlinks=domain&output=xml");
    $xml = simplexml_load_string($resp);
    echo $xml->ResultSet['totalResultsAvailable'];
    ?>
    PHP:
    But its not working...:/
     
    roice, Apr 7, 2010 IP
  2. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Its an attribute

    <?PHP
    $resp = file_get_contents("http://search.yahooapis.com/SiteExplorerService/V1/inlinkData?appid=YahooDemo&query=http://www.cnn.com&omit_inlinks=domain&output=xml");
    $xml = simplexml_load_string($resp);
    
    #echo $xml->ResultSet['totalResultsAvailable'];
    print $xml['totalResultsAvailable'];
    ?>
    PHP:
     
    lukeg32, Apr 7, 2010 IP
  3. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you,
    It's working.

    What did you mean by attribute?
    attribute is something that conect to XML?
     
    roice, Apr 8, 2010 IP
  4. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #4
    An attribute is something associated with a node (in this case its the parent tree but as an example)

    <xml>
    <person type="man">
    <heigh>tall</height>
    <haircolor>brown</haircolor>
    </person>
    </xml?

    in the above 'type="man"' is an attribute of person and these values and handled differently to the child nodes within person.
     
    lukeg32, Apr 8, 2010 IP
  5. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you
    ......
     
    roice, Apr 8, 2010 IP