Postingan

Menampilkan postingan dengan label Java xml tutorial

How to convert XMLGregorianCalendar to Date to XMLGregorianCalendar in Java - Example Tutorial

There are several ways to convert XMLGregorianCalendar to Date in Java. You can convert XMLGregorianCalendar to either java.util.Date or java.sql.Date based upon your need . JAXB (Java API/Architecture for XML Bindings) is a popular framework to create XML documents from Java Objects and Java objects from XML files. JAXB also helps to create Java classes from XML Schema file (.XSD file). By default JAXB maps XSD data type xs:date , xs:time and xs:dateTime to XMLGregorianCalendar in Java, but you can configure XJC to create java.util.Date objects instead of javax.xml.datatype.XMLGregorianCalendar . Sin ce java.util.Date is most popular way of dealing with date and time in Java, we often need to convert XMLGregorianCalendar instance to Date instance in Java. Thankfully by using Java API, we can easily do this conversion of XMLGregorianCalendar to Date and Date to XMLGregorianCalendar in Java. By the way, It's good to remember that XML Schema has three different types wh...

JAXB XML Binding tutorial - Marshalling UnMarshalling Java Object to XML

XML binding is a concept of generating Java objects from XML and opposite i.e. XML documents from Java object. Along with parsing XML documents using DOM and SAX parser , XML binding is a key concept to learn if you are working in a Java application which uses XML in any way e.g. for storing persistence data like user preferences or for transmitting messages between two systems etc. XML binding is also a popular XML Interview question in Java. JAXB and XMLBeans are two common ways to achieve XML binding in Java. XML binding, also known as XML marshaling and marshaling has two sides, first converting XML document to Java object, modify Java object and then converting back to an XML file. Once you have XML document as Java object, You can use the power of Java programming language to process and manipulate the XML elements, attributes etc. In last couple of Java XML tutorials, we have seen How to parse XML using DOM parser and How to evaluate XPATH expression in Java . Read more ...

How to Create and Evaluate XPath Expression in Java - Tutorial and Example

You can use XPathExpression from javax.xml.xpath package to create and execute XPATH expression in Java. Java API provides javax.xml.xpath package, which contains classes like Xpath , XpathFactory to work with XPATH and XML documents. By the way this is third article on Xpath, In last couple of tutorials e.g. XPATH examples to select values using attributes and my XPATH notes for Java programmer , we have seen basics of Xpath expression from XML and Java point of view. Anyone who has work with XML technologies in Java knows importance of XPATH, it is one the most useful technology to retrieve selected data from XML files. XPATH is like SQL which is used to retrieve data from relational database. Many back-office and middle-office Java application which transfers data in form of XML documents makes extensive use of XPATH expression to retrieve value for printing or for decision making. Though there are lot of open source XML libraries are available to assist with Java and XML ...

How to create and modify Properties file form Java program in Text and XML format

Though most of the time we create and modify properties file using text editor like notepad, word-pad or edit-plus, It�s also possible to create and edit properties file from Java program. Log4j.properties , which is used to configure Log4J based logging in Java and jdbc.properties which is used to specify configuration parameters for database connectivity using JDBC are two most common example of property file in Java. Though I have not found any real situation where I need to create properties file using Java program but it�s always good to know about facilities available in Java API. In last Java tutorial on Properties we have seen how to read values from properties file on both text and XML format and in this article we will see how to create properties file on both text and XML format. Java API�s java.util.Properties class provides several utility store() methods to store properties in either text or xml format. Store() can be used to store property in text properties file an...

XPath Tutorial - How to select elements in XPATH based on attribute and element value example

In this XPATH tutorial we will see example of selecting elements based upon its value or attribute value. We will see how to select between two elements based upon value of its child elements or based upon value of its attribute. XPATH is an important concept to understand if you are working with XML files. Most of Back-office platform relies on XML files for transporting data from one system to other and if you are working on any back-office or middle office system in Java or .NET, its important to know about XPATH and be able to use XPATH to select data from XML. Some time back I have shared my XPATH notes for Java programmer and this example shows true power of XPATH as how convenient its to made selective decision. For those who are completely new in XML and XPATH, XPATH is great xml tool which allows you to query XML document and select or retrieve selective data much like SQL but if you are new to XPATH or haven't had much experience with XML tool and technology than you wi...