XPath can be painful to get working. Usually when nothing comes out, then its a namespace issue. XPath must have namespaces defined if your XML have namspaces, which you do not have.
On Tue, Nov 22, 2011 at 5:02 PM, Castyn <eric.ben...@gmail.com> wrote: > Good to know. I have the body properly converting to a Document now. > > I suppose this may end up more of an XPath question, so I apologize in > advance but I have looked everywhere for some complicated examples and > haven't had much luck. > > Let's say this is the document that is coming into my custom processor and > being converted to a Document: > > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> > <soap:Body> > <ns2:hotelContentResponse > xmlns="http://atp.abv.com/schema/common/ATPCommonServiceTypes/v1" > > xmlns:ns2="http://atp.abc.com/schema/hotel/hcm/content/serviceDataTypes/v1" > > xmlns:ns3="http://atp.abc.com/schema/hotel/hcm/content/dataTypes/v1" > > xmlns:ns4="http://atp.abc.com/schema/common/content/serviceDataTypes/v1"> > <header> > <language isoCountryCode="US" > isoLanguageCode="en" /> > <headerVersion build="" major="1" minor="0" /> > <transactionStatus > overallStatusArea="HOTELCONTENT" > overallStatusCode="0000" overallStatusDescription="OK" > transactionSuccessful="true" /> > <serviceTransactionDuration > endTime="2011-11-21T11:21:46.906-05:00" > startTime="2011-11-21T11:21:46.390-05:00" /> > </header> > <ns2:hotelContent> > <ns4:contentList attributeNumber="718" > name="Airport Details"> > <ns4:compound attributeId="1390159538" > attributeNumber="718" > name="Airport Details" valueChangeDate="2009-07-01T04:00:00.000"> > <ns4:textLine > attributeId="1390159539" attributeNumber="719" > name="Airport Code" valueChangeDate="2009-07-01T04:00:00.000"> > > <ns4:text>ATL</ns4:text> > </ns4:textLine> > </ns4:compound> > <ns4:compound attributeId="1390159538" > attributeNumber="718" > name="Airport Details" valueChangeDate="2009-07-01T04:00:00.000"> > <ns4:textLine > attributeId="462364234" attributeNumber="719" > name="Airport Code" valueChangeDate="2009-07-01T04:00:00.000"> > > <ns4:text>NYC</ns4:text> > </ns4:textLine> > </ns4:compound> > </ns4:contentList> > </ns2:hotelContent> > </ns2:hotelContentResponse> > </soap:Body> > </soap:Envelope> > > I am trying to get a Node List of the airport codes (in this doc ATL and > NYC). What I have been trying is > > XPath xpath = XPathFactory.newInstance().newXPath(); > XPathExpression expr = xpath.compile("//textLine[attributeNumber='719']"); > > NodeList nodes = (NodeList)expr.evaluate(payload, XPathConstants.NODESET); > > for (int i = 0; i < nodes.getLength(); i++) { > // Do Stuff > } > > I am not sure if the document needs to have other information attached to it > such as XML version for xpath to treat it properly or if it is something > else, but I haven't been able to get any nodes returned at all on the > document, even when trying expressions as simple as "//hotelContent" and > such. Is there something I am missing? > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Custom-Processor-with-XPath-tp5011728p5013963.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- Claus Ibsen ----------------- FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/