You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by "Boutelle, Jonathan" <jo...@commerceone.com> on 2002/07/09 21:46:15 UTC
extracting text elements using xpath and xalan
Hello All,
I'm trying to extract a text element (the string "Response") from an xml doc
using xpath and xalan. My doc is below
<RoutingInfo>
<MessageType foo="bar">Response</MessageType>
</RoutingInfo>
My xpath (which doesn't work) is as follows:
/RoutingInfo/MessageType/child::*
However, if I use the following xpath instead
/RoutingInfo/MessageType/
I get back a DOM node that has a child node of type text.
My code is as follows:
InputSource in = new InputSource(new ByteArrayInputStream(docBytes));
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
dfactory.setNamespaceAware(false);
org.w3c.dom.Document doc = dfactory.newDocumentBuilder().parse(in);
Node n = XPathAPI.selectSingleNode(doc,
"RoutingInfo/MessageType/child::*");
Node n=getNodeFromDom(doc,"/RoutingInfo/MessageType/");
I presume that my xpath query is wrong, but it looks correct to me. Ideas?
Thanks in advance,
Jonathan Boutelle