Results 1 to 2 of 2
Thread: Interface Question
- 12-14-2010, 01:03 AM #1Member
- Join Date
- Dec 2010
- Rep Power
I am trying to create my own custom Node class. I am implementing the Node class and that seems to be working fine. I now need to use the NodeList class. I am grabbing the first element from the NodeList class and I need to somehow cast it to my CustomNode class...
String responseString; //a string of XML
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(responseString))); //convert to a DOM document
NodeList selected = document.getDocumentElement().getElementsByTagName (element); //Select the correct node
CustomNode selectedNode = selected.item(0);//ERROR here selected.item(0) returns a node and I am trying to use a class that implements the Node interface.
What am I doing wrong?
- 12-14-2010, 05:28 AM #2
- By RichWade in forum Advanced JavaReplies: 20Last Post: 11-29-2010, 07:26 PM
- By Minu in forum Java ServletReplies: 1Last Post: 01-16-2009, 11:33 AM
- By tony404 in forum Advanced JavaReplies: 2Last Post: 06-27-2008, 11:47 AM