how to parse a soap xmp result of amazon?

J

jacques

hello everybody

i'm really new to ruby and i have to step in a existing ruby projects.
i want to know what is the best way to access to xml elements.

how could i retrieve all BrowseNodeId's from the following result?
What would you suggest?
This is a .inspect result of the amazon response.

i looked at:
http://www.xml.com/pub/a/2005/11/09/rexml-processing-xml-in-ruby.html



#<SOAP::Mapping::Object:0x9a8dbe {http://webservices.amazon.com/
AWSECommerceService/
2007-10-29}OperationRequest=#<SOAP::Mapping::Object:0x9a8c60 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}HTTPHeaders=#<SOAP::Mapping::Object:0x9a8b2a {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Header=#<SOAP::Mapping::Object:0x9a89f4>> {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}RequestId="0TZD1KX81QY9WX8SH86V" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Arguments=#<SOAP::Mapping::Object:0x9a7f54 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Argument=#<SOAP::Mapping::Object:0x9a7e0a>> {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}RequestProcessingTime="0.0293409824371338"> {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Items=#<SOAP::Mapping::Object:0x9a71bc {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Request=#<SOAP::Mapping::Object:0x9a7072 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}IsValid="True" {http://webservices.amazon.com/
AWSECommerceService/
2007-10-29}ItemLookupRequest=#<SOAP::Mapping::Object:0x9a6c3a {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}IdType="ASIN" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}ItemId="B0000D8H9S" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}ResponseGroup="BrowseNodes">> {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Item=#<SOAP::Mapping::Object:0x9a5f38 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}ASIN="B0000D8H9S" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}BrowseNodes=#<SOAP::Mapping::Object:
0x9a5b3c {http://webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=[#<SOAP::Mapping::Object:0x9a59c0 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="4185471" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Alle N-Gage-Spiele" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Ancestors=#<SOAP::Mapping::Object:0x9a52a4 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0x9a5178 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="4010671" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name=" N-Gage" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Ancestors=#<SOAP::Mapping::Object:0x9a4a34 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0x9a4908 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="355008011" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Classics" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Ancestors=#<SOAP::Mapping::Object:0x9a41f6 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0x9a40a2 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="541708" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Plattformen" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}IsCategoryRoot="1" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Ancestors=#<SOAP::Mapping::Object:
0x9a3666 {http://webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0x9a3544 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="300992" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Games">>>>>>>>>,
#<SOAP::Mapping::Object:0xa7f5b2 {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}BrowseNodeId="382513011" {http://
webservices.amazon.com/AWSECommerceService/2007-10-29}Name="Plattform
(operating_system_browse-bin)" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Children=#<SOAP::Mapping::Object:
0xa7ef68 {http://webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=[#<SOAP::Mapping::Object:0xa7ee32 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="382514011" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Computerspiele">,
#<SOAP::Mapping::Object:0xa7e6bc {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}BrowseNodeId="382515011" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Name="Konsolen">, #<SOAP::Mapping::Object:0xa7e054 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="382516011" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Tragbare Konsolen">]> {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Ancestors=#<SOAP::Mapping::Object:0xa7d8a2 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0xa7d79e {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="366262011" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Refinements" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Ancestors=#<SOAP::Mapping::Object:0xa7d15e {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0xa7d01e {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="300992" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Games">>>>>,
#<SOAP::Mapping::Object:0xa7c448 {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}BrowseNodeId="382615011" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Name="Actionspiele" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Ancestors=#<SOAP::Mapping::Object:
0xa7be08 {http://webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0xa7bcfa {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="382614011" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Genre (feature_browse-
bin)" {http://webservices.amazon.com/AWSECommerceService/
2007-10-29}Ancestors=#<SOAP::Mapping::Object:0xa7b6c4 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0xa7b5ac {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="366262011" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Refinements" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Ancestors=#<SOAP::Mapping::Object:0xa7af08 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0xa7ae04 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="300992" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Games">>>>>>>,
#<SOAP::Mapping::Object:0xa7a062 {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}BrowseNodeId="405731011" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Name="Freigegeben ab 12 Jahren" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Ancestors=#<SOAP::Mapping::Object:0xa79a5e {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0xa7995a {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="405728011" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="USK-Einstufung
(age_range)" {http://webservices.amazon.com/AWSECommerceService/
2007-10-29}Ancestors=#<SOAP::Mapping::Object:0xa7927a {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0xa7913a {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="366262011" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Refinements" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Ancestors=#<SOAP::Mapping::Object:0xa789c4 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0xa7887a {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="300992" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Games">>>>>>>,
#<SOAP::Mapping::Object:0xa777c2 {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}BrowseNodeId="384027011" {http://
webservices.amazon.com/AWSECommerceService/2007-10-29}Name="Hidden
Node" {http://webservices.amazon.com/AWSECommerceService/
2007-10-29}Ancestors=#<SOAP::Mapping::Object:0xa7702e {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0xa76f02 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="365397011" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Software & Games f\303\274r
Kinder" {http://webservices.amazon.com/AWSECommerceService/
2007-10-29}Ancestors=#<SOAP::Mapping::Object:0xa767b4 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0xa7664c {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="526742" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Shops" {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}Ancestors=#<SOAP::Mapping::Object:0xa75d3c {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNode=#<SOAP::Mapping::Object:0xa75c24 {http://
webservices.amazon.com/AWSECommerceService/
2007-10-29}BrowseNodeId="300992" {http://webservices.amazon.com/
AWSECommerceService/2007-10-29}Name="Games">>>>>>>]>>>>


any hint welcome. thank you.
Jacques
 
R

Robert Klemme

2008/2/20 said:
hello everybody

i'm really new to ruby and i have to step in a existing ruby projects.
i want to know what is the best way to access to xml elements.

how could i retrieve all BrowseNodeId's from the following result?
What would you suggest?
This is a .inspect result of the amazon response.

i looked at:
http://www.xml.com/pub/a/2005/11/09/rexml-processing-xml-in-ruby.html

Also look at http://www.germane-software.com/software/rexml/docs/tutorial.html

Note especially XPath. For further documentation on how to build
XPath expressions, you can look here:

http://www.w3schools.com/xpath/
http://www.zvon.org/xxl/XPathTutorial/General/examples.html

Kind regards

robert
 
J

jacques

Also look athttp://www.germane-software.com/software/rexml/docs/tutorial.html
Note especially XPath. For further documentation on how to build
XPath expressions, you can look here:

http://www.w3schools.com/xpath/http://www.zvon.org/xxl/XPathTutorial/General/examples.html

Kind regards

robert


hi robert
thank you for the response.
i tried to use

doc = REXML::Document.new(xml_data)
in xml_data is the posted amazon response (with .inspect)

There is a Error:
in `parse': #<REXML::parseException: malformed XML: missing tag start
(REXML::parseException)

Would this mean that the Amazon Response has a Problem?
How must xmm_data be given to REXML::Document.new()?

Ideas?

Thank you.
Rergards
Jacques
 
R

Robert Klemme

2008/2/20 said:
hi robert
thank you for the response.
i tried to use

doc = REXML::Document.new(xml_data)
in xml_data is the posted amazon response (with .inspect)

If this is supposed to mean that you stuffed the result of invoking
#inspect on what you pulled from Amazon then this is certainly not
going to work.
There is a Error:
in `parse': #<REXML::parseException: malformed XML: missing tag start
(REXML::parseException)

Would this mean that the Amazon Response has a Problem?
How must xmm_data be given to REXML::Document.new()?

As plain XML - see above.

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top