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?
Asked
Active
Viewed 666 times
1
-
take a look here: [Parsing XML file using Xpath in jdk1.4][1] [1]: http://stackoverflow.com/questions/5094116/parsing-xml-file-using-xpath-in-jdk1-4 – Andrei Sfat Sep 13 '12 at 05:31
-
I need to use built-in libraries, without any external classes, if it's possible. – Leonid Sep 13 '12 at 05:57
-
java.xml.xpath was implemented since 1.5 only...so there is no other solution – Andrei Sfat Sep 13 '12 at 06:45
1 Answers
1
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.

user207421
- 305,947
- 44
- 307
- 483
-
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) – Leonid Sep 13 '12 at 07:42
-
When you say "I need no use", did you mean "I need to use" or "I need not use"? – Michael Kay Sep 13 '12 at 09:07
-
@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? – user207421 Sep 13 '12 at 11:00