I'm trying to handle the data coming from the Adwords API with XML::Simple, which seems to be a decent choice for it, but I can't seem to grab the values that I need, which are just so deep into the XML. I'm not sure where I'm wrong, but maybe you can help:
#!/usr/bin/perl -w
use strict;
use XML::Simple;
use Data::Dumper;
my $content = XMLin(qq|
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel
+ope/" 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/n
+ext" soapenv:mustUnderstand="0" xmlns="https://adwords.google.com/api
+/adwords/v5">124</responseTime>
<operations soapenv:actor="http://schemas.xmlsoap.org/soap/actor/nex
+t" soapenv:mustUnderstand="0" xmlns="https://adwords.google.com/api/a
+dwords/v5">1</operations>
<units soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" so
+apenv:mustUnderstand="0" xmlns="https://adwords.google.com/api/adword
+s/v5">25</units>
<requestId soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next
+" soapenv:mustUnderstand="0" xmlns="https://adwords.google.com/api/ad
+words/v5">123</requestId>
</soapenv:Header>
<soapenv:Body>
<getKeywordVariationsResponse xmlns="https://adwords.google.com/api/
+adwords/v5">
<getKeywordVariationsReturn>
<moreSpecific>
<text>web content managment</text>
<language>en</language>
<advertiserCompetitionScale>3</advertiserCompetitionScale>
<searchVolumeScale>1</searchVolumeScale>
</moreSpecific>
<moreSpecific>
<text>web based content management</text>
<language>en</language>
<advertiserCompetitionScale>5</advertiserCompetitionScale>
<searchVolumeScale>1</searchVolumeScale>
</moreSpecific>
<additionalToConsider>
<text>3.14</text>
<language>en</language>
<advertiserCompetitionScale>3</advertiserCompetitionScale>
<searchVolumeScale>2</searchVolumeScale>
</additionalToConsider>
<additionalToConsider>
<text>babinet's</text>
<language>en</language>
<advertiserCompetitionScale>2</advertiserCompetitionScale>
<searchVolumeScale>0</searchVolumeScale>
</additionalToConsider>
</getKeywordVariationsReturn>
</getKeywordVariationsResponse>
</soapenv:Body>
</soapenv:Envelope>
|);
print "... $content->{'soapenv:Envelope'}{'soapenv:Body'}{'getKeywordV
+ariationsResponse'}{'getKeywordVariationsReturn'}{'moreSpecific'}[0]-
+>{'text'} ...\n";
#print Dumper(\$content);
This returns me nothing, and I even get the fun uninitialized statement:
Use of uninitialized value in concatenation (.) or string at xmlparser
+.pl line 54.
Any ideas? Obviously I need what's in the text, advertiserCompetitionScale, and searchVolume tags, and I need to iterate through each occurrence. Any ideas?