What is it? JAX-B is the Java specification that allows us to directly associate a class to an XML file, … More
Tag: xml
[Java] – How to use XPath to parse XML files?
What is it ? The xPath allows us to select only a part of our document using a very similar … More
[JAVA] – How to use a StAX to parse a XML file ? You can get a list with all data.
What is it ? The StAX, which has a very similar operation with SAX. It is also based on events, … More
[JAVA] – How to use SAX to parse a XML file?
First you need implement the class where you will specify the attributes of your file. Look the code below. public … More
[JAVA] – How to validate a XML ?
For do this is easy : DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(true); factory.setNamespaceAware(true); factory.setAttribute(“http://java.sun.com/xml/jaxp/properties/schemaLanguage”, “http://www.w3.org/2001/XMLSchema”);
[JAVA] – How to read a XML file ?
Below is an example for do it. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(“src/products.xml”); NodeList … More