I have a sourcecode of class, that has been written on Java 1.6 and uses XPath to get XML from InputStream and make some specific changes in XML Document. Now a I have to make this class compatible with Java 1.4. Netbeans highlight import rows for XPath classes "javax.xml.xpath.*". What alternatives of XPath I can use to get NodeList from InputStream whith XML in Java 1.4?
-
take a look here: [Parsing XML file using Xpath in jdk1.4][1] [1]: stackoverflow.com/questions/5094116/…Andrei Sfat– Andrei Sfat2012-09-13 05:31:34 +00:00Commented Sep 13, 2012 at 5:31
-
I need to use built-in libraries, without any external classes, if it's possible.Leonid– Leonid2012-09-13 05:57:58 +00:00Commented Sep 13, 2012 at 5:57
-
java.xml.xpath was implemented since 1.5 only...so there is no other solutionAndrei Sfat– Andrei Sfat2012-09-13 06:45:40 +00:00Commented Sep 13, 2012 at 6:45
Add a comment
|
1 Answer
Your question including your commentary comprises a contradiction in terms. The XPath libraries were not built in to JDK 1.4, they are @since 1.5, although they were available separately in the JAXP part of the Web Services pack (JAX-WS?) for a while before that.
You will have to add and use either JAXP from the external bundle or use Apache Xalan directly, like it or not.
3 Comments
Leonid
I need no use XPath directly. I need to get NodeList from XML, than copy some nodes to new, Document, modify some nodes in new Document and rename modified nodes, than return new XML. Now I'm trying use DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputSource) instead xpath.evaluate(expression, inputSource, XPathConstants.NODESET)
Michael Kay
When you say "I need no use", did you mean "I need to use" or "I need not use"?
user207421
@Leonid What exactly does your comment have to do with my answer? Was there something about it that needs clarifying? And how does using
DocumentBuilder.parse() constitute using XPath at all?