DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Java DOM: Sample XPath Query

05.14.2007
| 18796 views |
  • submit to reddit
        
    try
    {
      XPath xpath = XPathFactory.newInstance().newXPath();
      Element e = (Element) xpath.evaluate("/Archive/Section/Description", parentNode,
          XPathConstants.NODE);
      printXmlNode(e);
    }
    catch (XPathExpressionException e)
    {
      e.printStackTrace();
    }
    

Comments

Snippets Manager replied on Sun, 2008/08/24 - 2:30am

Make sure you have the proper imports in your code: import javax.xml.xpath.*;

Sharad Sharma replied on Tue, 2007/10/23 - 12:09am

anyone has any idea about how to create XML from a DTD file using JAVA