SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2008
    Posts
    159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy help me plz in this google xml code using php

    hi ,

    i have xml code , i recive it from google api , i want take from this code , all <ns1:text> value , and all <ns1:avgSearchVolume> for each element , so how to do this plz ?

    this is the xml code :
    Code XML:
     
     
    HTTP/1.1 200 OK
    Content-Type: text/xml; charset=utf-8
    Transfer-Encoding: chunked
    Date: Thu, 11 Jun 2009 13:25:33 GMT
    Expires: Thu, 11 Jun 2009 13:25:33 GMT
    Cache-Control: private, max-age=0
    X-Content-Type-Options: nosniff
    Server: GFE/2.0
     
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <soapenv:Header>
      <responseTime soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns="https://adwords.google.com/api/adwords/v13">1132</responseTime>
      <operations soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns="https://adwords.google.com/api/adwords/v13">1</operations>
      <units soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns="https://adwords.google.com/api/adwords/v13">20</units>
      <requestId soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns="https://adwords.google.com/api/adwords/v13">3402a213</requestId>
     </soapenv:Header>
     <soapenv:Body>
      <getKeywordVariationsResponse xmlns="">
       <ns1:getKeywordVariationsReturn xmlns:ns1="https://adwords.google.com/api/adwords/v13">
        <ns1:moreSpecific>
         <ns1:text> abc1 </ns1:text>
         <ns1:language></ns1:language>
         <ns1:advertiserCompetitionScale>3</ns1:advertiserCompetitionScale>
         <ns1:avgSearchVolume>8100</ns1:avgSearchVolume>
         <ns1:lastMonthSearchVolume>-1</ns1:lastMonthSearchVolume>
        </ns1:moreSpecific>
     
        <ns1:moreSpecific>
         <ns1:text> abc2 </ns1:text>
         <ns1:language></ns1:language>
         <ns1:advertiserCompetitionScale>0</ns1:advertiserCompetitionScale>
         <ns1:avgSearchVolume>140</ns1:avgSearchVolume>
         <ns1:lastMonthSearchVolume>-1</ns1:lastMonthSearchVolume>
        </ns1:moreSpecific>
     
        <ns1:moreSpecific>
         <ns1:text> abc3 </ns1:text>
         <ns1:language></ns1:language>
         <ns1:advertiserCompetitionScale>0</ns1:advertiserCompetitionScale>
         <ns1:avgSearchVolume>36</ns1:avgSearchVolume>
         <ns1:lastMonthSearchVolume>-1</ns1:lastMonthSearchVolume>
        </ns1:moreSpecific>
     
        <ns1:moreSpecific>
         <ns1:text> abc4 </ns1:text>
         <ns1:language></ns1:language>
         <ns1:advertiserCompetitionScale>0</ns1:advertiserCompetitionScale>
         <ns1:avgSearchVolume>110</ns1:avgSearchVolume>
         <ns1:lastMonthSearchVolume>-1</ns1:lastMonthSearchVolume>
        </ns1:moreSpecific>
     
     
        <ns1:additionalToConsider>
         <ns1:text> def1 </ns1:text>
         <ns1:language></ns1:language>
         <ns1:advertiserCompetitionScale>4</ns1:advertiserCompetitionScale>
         <ns1:avgSearchVolume>450000</ns1:avgSearchVolume>
         <ns1:lastMonthSearchVolume>1900</ns1:lastMonthSearchVolume>
        </ns1:additionalToConsider>
     
        <ns1:additionalToConsider>
         <ns1:text> def2 </ns1:text>
         <ns1:language></ns1:language>
         <ns1:advertiserCompetitionScale>4</ns1:advertiserCompetitionScale>
         <ns1:avgSearchVolume>450000</ns1:avgSearchVolume>
         <ns1:lastMonthSearchVolume>1900</ns1:lastMonthSearchVolume>
        </ns1:additionalToConsider>
     
        <ns1:additionalToConsider>
         <ns1:text> def3 </ns1:text>
         <ns1:language></ns1:language>
         <ns1:advertiserCompetitionScale>4</ns1:advertiserCompetitionScale>
         <ns1:avgSearchVolume>450000</ns1:avgSearchVolume>
         <ns1:lastMonthSearchVolume>1900</ns1:lastMonthSearchVolume>
        </ns1:additionalToConsider>
     
     
       </ns1:getKeywordVariationsReturn>
      </getKeywordVariationsResponse>
     </soapenv:Body>
    </soapenv:Envelope>

    note : this xml value is stored in php string with name $xml_value

    i want store each text ant each avgSearchVolume for each element in database

    wait your help please quiqly
    wait your help plz

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    // strip the response headers
    $pos strpos($xml_value'<');
    $new_xml substr($xml_value$pos);

    // load into simplexml object
    $xml simplexml_load_string($new_xml);
    $xml->registerXPathNamespace('ns1''https://adwords.google.com/api/adwords/v13');

    // grab the goodies
    $texts $xml->xpath('//ns1:text');
    $volume $xml->xpath('//ns1:avgSearchVolume');

    // print them out
    for ($i=0$i<sizeof($texts); $i++)
      {
        echo 
    'text: ' $texts[$i] . '<br />';
        echo 
    'volume: ' $volume[$i] . '<br />';
      } 


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
  •