Source
<dsl:select-list-set xmlns:dsl="http://www.applyweb.com/dsl";>
        <dsl:select-list name="MAJOR" id="Major" />
        <dsl:select-list name="DEGREE" id="Degree" />
</dsl:select-list-set>

I'm trying to query a DOM tree in Java as follows...

// Set up a DOM tree to query.
InputSource in = new InputSource(new FileInputStream(inFile));
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
dfactory.setNamespaceAware(true);
Document doc = dfactory.newDocumentBuilder().parse(in);
                
Node n1 = XPathAPI.selectSingleNode(doc, "//name");
Node n2 = XPathAPI.selectSingleNode(doc, "//address");

The call to selectSingleNode() code works until I look for an element with a namespace which results in the following error...
Node n3 = XPathAPI.selectSingleNode(doc, "//dsl:select-list-set");
Exception in thread "main" javax.xml.transform.TransformerException: Prefix must resolve to a namespace: dsl


How do I declare and pass the method selectSingleNode() a namespace node as a third parameter.
Jim




Reply via email to