ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MbXPath Problem

Post new topic  Reply to topic
 MbXPath Problem « View previous topic :: View next topic » 
Author Message
deepnair
PostPosted: Tue Apr 03, 2012 2:22 pm    Post subject: MbXPath Problem Reply with quote

Apprentice

Joined: 07 Feb 2012
Posts: 35

Im trying for an XPath in my java code, the first one below i.e. getFirstElementByPath works and returns the value but when i xpath, its not working, the node list size returned is 0.

The below code works
Code:

outBody.getFirstElementByPath("./se:Envelope/se:Header/aa:Action").getValue().toString()


But when I try an xpath it does not work
Code:

         MbXPath xPath = new MbXPath("./se:Envelope/se:Header/aa:Action");
         xPath.addNamespacePrefix("se",
               "http://www.w3.org/2003/05/soap-envelope");
         xPath.addNamespacePrefix("def", "http://def.com/envelope");
         xPath.addNamespacePrefix("aa", "http://aa.com/aaV001");
         List listHeader = (List) outBody.evaluateXPath(xPath);
         log.debug("# of elements is ** - " + listHeader.size());


Why is xpath not pointing to the element though it exists ?

Thanks,
Deep Nair
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Apr 03, 2012 7:43 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Have you taken a user trace to see why the xpath is not working?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqsiuser
PostPosted: Tue Apr 03, 2012 8:50 pm    Post subject: Re: MbXPath Problem Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

Code:
outBody.getFirstElementByPath("./se:Envelope/se:Header/aa:Action").getValue().toString()

MbXPath xPath = new MbXPath("./se:Envelope/se:Header/aa:Action");


1. It says "get by path" and not "get by xpath"

2 . Read w3schools (the parts on xPath), and then the w3c standard/recommendation on xpath

3. Use an xpath editor or xml editor, e.g. oXygen (rightclick there on an xml element/attribute and select "copy XPath")

4. Try removing the leading dot (.)

5. Recheck if your namespaces are correctly set, e.g. you are defining "def" (seems like for envelope), but then use "se:" (for the envelope)

6. Indicate your (exact) intentions (this will help the parser to perform better):

Code:
MbXPath("/se:Envelope[1]/se:Header[1]/aa:Action[1]");


If nothing matches your xPath expression the result (node set) will just be empy (and you will not have an exception/error)... so if there really/actually should be something (returning from your query) I suppose it is up to you to throw an exception (base on a check for "is empty" on the xpath-result-set).
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
zhumingvictor
PostPosted: Fri May 10, 2013 7:43 am    Post subject: Reply with quote

Novice

Joined: 10 May 2013
Posts: 17

Hi, I am having the same problem. Did you get it solved?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MbXPath Problem
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.