You are right there is a namespace declaration but none of the tags are qualified.

Perhaps the doc should give some examples where this applies or at least point to xpath doco where it is explained or maybe a heads up.

I am using dom4j with amazon web services

Here is a sample document

<SellerLookupResponse>

-

            <OperationRequest>

-

            <HTTPHeaders>

<Header Name="UserAgent" Value="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3"/>

</HTTPHeaders>

<RequestId>1170KAT2BX34T5A9R376</RequestId>

-

            <Arguments>

<Argument Name="Service" Value="AWSECommerceService"/>

<Argument Name="SellerId" Value="A3B9364CV8QDO9"/>

<Argument Name="SubscriptionId" Value="0JVZH2VP1MH3ZHTC5CR2"/>

<Argument Name="Operation" Value="SellerLookup"/>

</Arguments>

<RequestProcessingTime>0.114522933959961</RequestProcessingTime>

</OperationRequest>

-

            <Sellers>

-

            <Request>

<IsValid>True</IsValid>

-

            <SellerLookupRequest>

<SellerId>A3B9364CV8QDO9</SellerId>

</SellerLookupRequest>

</Request>

-

            <Seller>

<SellerId>A3B9364CV8QDO9</SellerId>

<Nickname>jwlaw2</Nickname>

-

            <GlancePage>

http://www.amazon.com/gp/help/seller/at-a-glance.html?seller=A3B9364CV8QDO9&marketplaceSeller=1

</GlancePage>

-

            <Location>

<City>Emeryville</City>

<State>CA</State>

</Location>

<AverageFeedbackRating>4.9</AverageFeedbackRating>

<TotalFeedback>511</TotalFeedback>

<TotalFeedbackPages>103</TotalFeedbackPages>

-

            <SellerFeedback>

-

            <Feedback>

<Rating>5</Rating>

<Comment>Fast shipment, great condition</Comment>

<Date>2005-05-11T14:59+0000</Date>

<RatedBy>A2HGZ671D256VO</RatedBy>

</Feedback>

-

            <Feedback>

<Rating>5</Rating>

<Comment>as represented - thanks</Comment>

<Date>2005-05-11T13:17+0000</Date>

<RatedBy>A726Z2XMZN6AK</RatedBy>

</Feedback>

-

            <Feedback>

<Rating>5</Rating>

<Comment>Great products!</Comment>

<Date>2005-05-11T12:57+0000</Date>

<RatedBy>A34M7W7WBRCQSR</RatedBy>

</Feedback>

-

            <Feedback>

<Rating>5</Rating>

<Comment>Fast shipping. Great CD's. Thank you</Comment>

<Date>2005-05-11T00:41+0000</Date>

<RatedBy>A1O36N63YNHZ1H</RatedBy>

</Feedback>

-

            <Feedback>

<Rating>5</Rating>

-

            <Comment>

arrived very fast by airmail upgrade to normal post

</Comment>

<Date>2005-05-10T05:33+0000</Date>

<RatedBy>A1YOHDWW2CW6BU</RatedBy>

</Feedback>

</SellerFeedback>

</Seller>

</Sellers>

</SellerLookupResponse>

 

Sorry about the lousy formatting.

Thanks for the quick reply…

Steve

 


From: Maarten Coene [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 10, 2005 11:07 PM
To: Steven Citron-Pousty; dom4j-user@lists.sourceforge.net
Subject: Re: [dom4j-user] change in xpath syntax

 

Steven,

 

I think the reason is that your XML file contains namespace declarations.

 

But to be sure: could you send us a sample of your XML file and some sample code illustrating your problem

 

regards,

Maarten

Steven Citron-Pousty <[EMAIL PROTECTED]> wrote:

I am using dom4j 1.6 with jaxen 1-1 beta 6 but I also tried this with beta 4.

In my old code I could use xpath syntax like this

List list = root.selectNodes( "//SellerId" );

And I would get all the SellerID nodes.

I tried that with the new dom4j code and I kept getting an empty list.

I had dom4j tell me the xpath for the root node and it said the syntax has to look like this:

/*[name()='ItemLookupResponse']

So my code above became this:

List list = root.selectNodes( "//*[name()='SellerId']" );

 

Which now gives me a list of 9 objects.

Both xpath syntax styles work in xmlSpy but my original style is much cleaner. Why did the style change or why doesn’t the first style work anymore? I noticed that the tests use the old style (in the zip I downloaded for 1.6) and all the tests pass according to the maven doc.

How is this the case?

 

Most importantly, if the second style is the only working style, someone has to update all the examples since they use the style of the first syntax.

Thanks,

Steve


Discover Yahoo!
Find restaurants, movies, travel & more fun for the weekend. Check it out!

Reply via email to