I am using a framework: vaadin, I have a NodeSet data;
and I use it like that: data.toXMLString();
I get all the XML so no problem with this. But I want to parse data.toXMLString();
to push all the information into a tree. I watched a lot of forums, conversations in stackoverflow/openclassroom and others but each time the XML is a file, and it doesn't works with mine. Here what I started to do :
private void getData(NodeSet data){
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try{
final DocumentBuilder builder = factory.newDocumentBuilder();
final Document document = builder.parse(data.toXMLString());
final Element racine = document.getDocumentElement();
System.out.print(racine.getNodeName());
final NodeList racineNoeuds = racine.getChildNodes();
final int nbRacineNoeuds = racineNoeuds.getLength();
for(int i = 0; i < nbRacineNoeuds; i++){
if(racineNoeuds.item(i).getNodeType() == Node.ELEMENT_NODE) {
final Element child = (Element) racineNoeuds.item(i);
}
}
} catch (final ParserConfigurationException e){
e.printStackTrace();
} catch (final SAXException e){
e.printStackTrace();
} catch (final IOException e){
e.printStackTrace();
}
tree.addItem(data.toXMLString());
}
I don't finish it because when I launch my server I have this error :
java.net.MalformedURLException
at this line : final Document document = builder.parse(data.toXMLString());
So if you have any idea. Thank you.