9

I have this code in eclipse

NodeSet nodes = (NodeSet) xPath.evaluate(expression,inputSource, XPathConstants.NODESET);

and its giving me compile time error on NodeSet.

These are the stuff that I have imported. Can you tell me why it's doing this?

import javax.xml.xpath.*;
import org.xml.sax.InputSource;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;
Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431
denniss
  • 17,229
  • 26
  • 92
  • 141

1 Answers1

18

As indicated NodeSet is not part of the standard libraries. However, from the documentation, NodeSet maps to a NodeList, so you could just use that instead. So it would become:

NodeList nodes = (NodeList) xPath.evaluate(expression,inputSource, XPathConstants.NODESET);

You would have to import org.w3c.dom.NodeList.

Garett
  • 16,632
  • 5
  • 55
  • 63