Results 1 to 4 of 4
Thread: Help with xml
- 06-25-2007, 04:26 AM #1
Senior Member
- Join Date
- Jun 2007
- Posts
- 130
- Rep Power
- 0
- 07-02-2007, 02:58 AM #2
Senior Member
- Join Date
- Jun 2007
- Posts
- 164
- Rep Power
- 13
This is strange.
Can you send the exact error ?
- 07-02-2007, 03:00 AM #3
Senior Member
- Join Date
- Jun 2007
- Posts
- 132
- Rep Power
- 0
please start to this tutorial
Working with XML: The Java/XML Tutorial
- 03-28-2008, 06:29 PM #4
You could use xpath to search through an XML document.
Here is an example:
Java Code:DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringComments(true); DocumentBuilder parser = dbf.newDocumentBuilder(); Document doc = parser.parse(yourfile.xml); String text = "Text to search for"; // look for the text somewhere in a nested Element XPath xpath = XPathFactory.newInstance().newXPath(); NodeList nodes = (NodeList)xpath.evaluate("//*[contains(text(),'" + text + "')]", doc, XPathConstants.NODESET); for (int i = 0, n = nodes.getLength(); i < n; i++) { Node node = nodes.item(i); String path; path = node.getNodeName() + '/' + node.getTextContent() }
Did this post help you? Pleaseme! :cool:
Bookmarks