Hey,
Couldn't find anything about this here or on google (although maybe I
should be posting to the jaxen group) -- but I'm having a really wierd
issues using XPath and dom4j and the Amazon Web Service (AWS).
here's some sample code:
URL url = new
URL("http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=0XJ88X7PMVVRDE672202&Operation=ItemSearch&Keywords=John%20Steinbeck&SearchIndex=Books&Sort=reviewrank");
SAXReader reader = new SAXReader();
Document document = reader.read(url);
That url will retrieve a valid XML document. But the wierd part is
when I try to get back a list of nodes via xpath, I get some really
strange behavior:
This code will return a list of nodes:
List nodes = document.selectNodes( "//*[name()='Item']" );
But this code returns null:
List nodes = document.selectNodes( "//Item" );
That should be a totally legit XPath expression. In fact, they should
be more or less equivalent. Other XPath/dom4j stuff I've done works
great using that less formal syntax. Is there something funky about
the Amazon XML in particular? When I loaded this XML in XPE I get the
same results as with dom4j. I've attached some xml output from amazon
below.
Any help would be greatly appreciated,
-Joe Rosenblum
<ItemSearchResponse
xmlns="http://webservices.amazon.com/AWSECommerceService/2004-11-10">
<OperationRequest>
<HTTPHeaders>
<Header Name="UserAgent" Value="Java/1.4.2_05"/>
</HTTPHeaders>
<RequestId>0TNXR7V2NXJKP05AH0W5</RequestId>
<Arguments>
<Argument Name="Service" Value="AWSECommerceService"/>
<Argument Name="AssociateTag" Value="25thstreetnet-20"/>
<Argument Name="SearchIndex" Value="Books"/>
<Argument Name="SubscriptionId" Value="0XJ88X7PMVVRDE672202"/>
<Argument Name="Keywords" Value="java"/>
<Argument Name="Sort" Value="reviewrank"/>
<Argument Name="Operation" Value="ItemSearch"/>
</Arguments>
<RequestProcessingTime>0.0779130458831787</RequestProcessingTime>
</OperationRequest>
<Items>
<Request>
<IsValid>True</IsValid>
<ItemSearchRequest>
<Keywords>java</Keywords>
<SearchIndex>Books</SearchIndex>
<Sort>reviewrank</Sort>
</ItemSearchRequest>
</Request>
<TotalResults>3420</TotalResults>
<TotalPages>342</TotalPages>
<Item>
<ASIN>0201310058</ASIN>
<DetailPageURL>http://www.amazon.com/exec/obidos/redirect?tag=25thstreetnet-20%26link_code=xm2%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=0201310058%2526location=/o/ASIN/0201310058%25253FSubscriptionId=0XJ88X7PMVVRDE672202</DetailPageURL>
<ItemAttributes>
<Author>Joshua Bloch</Author>
<ProductGroup>Book</ProductGroup>
<Title>Effective Java Programming Language Guide</Title>
</ItemAttributes>
</Item>
<Item>
<ASIN>0201310023</ASIN>
<DetailPageURL>http://www.amazon.com/exec/obidos/redirect?tag=25thstreetnet-20%26link_code=xm2%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=0201310023%2526location=/o/ASIN/0201310023%25253FSubscriptionId=0XJ88X7PMVVRDE672202</DetailPageURL>
<ItemAttributes>
<Author>Patrick Chan</Author>
<Author>Rosanna Lee</Author>
<Author>Douglas Kramer</Author>
<ProductGroup>Book</ProductGroup>
<Title>The Java Class Libraries, Volume 1: java.io, java.lang,
java.math, java.net, java.text, java.util (2nd Edition)</Title>
</ItemAttributes>
</Item>
<Item>
<ASIN>0072127422</ASIN>
<DetailPageURL>http://www.amazon.com/exec/obidos/redirect?tag=25thstreetnet-20%26link_code=xm2%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=0072127422%2526location=/o/ASIN/0072127422%25253FSubscriptionId=0XJ88X7PMVVRDE672202</DetailPageURL>
<ItemAttributes>
<Author>Herbert Schildt</Author>
<ProductGroup>Book</ProductGroup>
<Title>Java 2: A Beginner's Guide</Title>
</ItemAttributes>
</Item>
<Item>
<ASIN>1861007841</ASIN>
<DetailPageURL>http://www.amazon.com/exec/obidos/redirect?tag=25thstreetnet-20%26link_code=xm2%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=1861007841%2526location=/o/ASIN/1861007841%25253FSubscriptionId=0XJ88X7PMVVRDE672202</DetailPageURL>
<ItemAttributes>
<Author>Rod Johnson</Author>
<ProductGroup>Book</ProductGroup>
<Title>Expert One-on-One J2EE Design and Development</Title>
</ItemAttributes>
</Item>
<Item>
<ASIN>0672315858</ASIN>
<DetailPageURL>http://www.amazon.com/exec/obidos/redirect?tag=25thstreetnet-20%26link_code=xm2%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=0672315858%2526location=/o/ASIN/0672315858%25253FSubscriptionId=0XJ88X7PMVVRDE672202</DetailPageURL>
<ItemAttributes>
<Author>Paul Hyde</Author>
<ProductGroup>Book</ProductGroup>
<Title>Java Thread Programming</Title>
</ItemAttributes>
</Item>
<Item>
<ASIN>186100382X</ASIN>
<DetailPageURL>http://www.amazon.com/exec/obidos/redirect?tag=25thstreetnet-20%26link_code=xm2%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=186100382X%2526location=/o/ASIN/186100382X%25253FSubscriptionId=0XJ88X7PMVVRDE672202</DetailPageURL>
<ItemAttributes>
<Author>Brett Spell</Author>
<ProductGroup>Book</ProductGroup>
<Title>Professional Java Programming</Title>
</ItemAttributes>
</Item>
<Item>
<ASIN>0735617791</ASIN>
<DetailPageURL>http://www.amazon.com/exec/obidos/redirect?tag=25thstreetnet-20%26link_code=xm2%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=0735617791%2526location=/o/ASIN/0735617791%25253FSubscriptionId=0XJ88X7PMVVRDE672202</DetailPageURL>
<ItemAttributes>
<Author>Allen Jones</Author>
<Author>Adam Freeman</Author>
<ProductGroup>Book</ProductGroup>
<Title>C# for Java Developers</Title>
</ItemAttributes>
</Item>
<Item>
<ASIN>0201634589</ASIN>
<DetailPageURL>http://www.amazon.com/exec/obidos/redirect?tag=25thstreetnet-20%26link_code=xm2%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=0201634589%2526location=/o/ASIN/0201634589%25253FSubscriptionId=0XJ88X7PMVVRDE672202</DetailPageURL>
<ItemAttributes>
<Author>Patrick Chan</Author>
<Author>Rosanna Lee</Author>
<ProductGroup>Book</ProductGroup>
<Title>The Java Class Libraries: An Annotated Reference (Java
Series)</Title>
</ItemAttributes>
</Item>
<Item>
<ASIN>B00007FYH1</ASIN>
<DetailPageURL>http://www.amazon.com/exec/obidos/redirect?tag=25thstreetnet-20%26link_code=xm2%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=B00007FYH1%2526location=/o/ASIN/B00007FYH1%25253FSubscriptionId=0XJ88X7PMVVRDE672202</DetailPageURL>
<ItemAttributes>
<Author>Ruth Maran</Author>
<Author>Martine Edwards</Author>
<ProductGroup>Book</ProductGroup>
<Title>Teach Yourself Visually HTML</Title>
</ItemAttributes>
</Item>
<Item>
<ASIN>0131422464</ASIN>
<DetailPageURL>http://www.amazon.com/exec/obidos/redirect?tag=25thstreetnet-20%26link_code=xm2%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=0131422464%2526location=/o/ASIN/0131422464%25253FSubscriptionId=0XJ88X7PMVVRDE672202</DetailPageURL>
<ItemAttributes>
<Author>Deepak Alur</Author>
<Author>Dan Malks</Author>
<Author>John Crupi</Author>
<ProductGroup>Book</ProductGroup>
<Title>Core J2EE Patterns: Best Practices and Design
Strategies, Second Edition</Title>
</ItemAttributes>
</Item>
</Items>
</ItemSearchResponse>
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
dom4j-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dom4j-user