Showing posts with label Java xml tutorial. Show all posts
Showing posts with label Java xml tutorial. Show all posts

Sunday 25 August 2013

Top Most How to create and evaluate XPath Expression in Java:

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 development e.g. XML Beans. I personally prefer to use standard Java API if  functionality is available there. In this Java tutorial we will learn how to create XPath expression in Java program and retrieving values from XPATH e.g. text, numbers and boolean values, which is critical for programming flow.
Read more »

Saturday 24 August 2013

Top Most 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 system 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 than converting back to XML file. Once you have XML document as Java object, You can use 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. In this Java XML tutorial we will talk about JAXB (Java API for XML Binding) which is an annotation based library integrated into Java SDK. Beauty of JAXB is that it doesn't require XML Schema to generate XML documents from Java objects unlike XMLBeans and simply rely on POJO(Plain old Java objects) and annotations.
Read more »

Top Most 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 and  storeToXML() method can be used for creating a Java property file in XML format.
Read more »

Thursday 22 August 2013

Top Most 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 will struggle to find correct syntax of XPATH for your different need.
Read more »

Thursday 15 August 2013

Top Most 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. Since java.util.Dateis 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 which can represent either date, time or both, while java.util.Date contains date and time information together. In this Java and XML tutorial, we will see example of converting XMLGregorianCalendar to Date and inverse in Java.
Read more »

Thursday 1 August 2013

Top Most How to replace escape XML special characters in Java String

How to replace XML special Characters in Java String
There are two approaches to replace XML or HTML special characters from Java String, First,  Write your own function to replace XML special characters or use any open source library which has already implemented it. Luckily there is one very common open source library which provides function to replace special characters from XML String is Apache commons lang’s StringEscapeUtils class which provide escaping for several  languages like XML, SQL and HTML. you can use StringEscapeUtils to convert XML special character in String to there escaped equivalent. I personally like to use open source code instead of reinventing the wheel to avoid any testing efforts. Even Joshua Bloach as advocated use of Open source library to leverage experience and work of other programers. If you are reading from XML file andafter doing some transformation writing to another XML file , you need to take care of XML special characters present in source file. If you don’t escape XML special characters while creating XML document than various XML parsers like DOM and SAX parser will consider those XML meta consider them as XML tag in case of < or >. Even if you try to transform XML with special character using  XSLT transformation, it will complain and fail. So while generating XML documents its very important to escape XML special characters to avoid any parsing or transformation issues. In this Java XML tutorial we will see What is special characters in XML and how to escape XML characters from Java String.
Read more »

LinkWithin

Related Posts Plugin for WordPress, Blogger...

Labels

Core Java programming core java interview question Core Java Faq's Servlets coding database jsp-servlet spring Java linux unix interview questions java investment bank Web Services Interview investment bank mysql Senior java developer interviews best practices java collection tutorial RMI SQL Eclipse FIX protocol tutorial tibco J2EE groovy java questions SCJP grails java 5 tutorial jdbc beginner error and exception Design Patterns Java Programming Tutorials fundamentals general object oriented programming xml Java Programs Hibernate Examples Flex JAMon Java xml tutorial logging Jsp Struts 2.0 Sybase and SQL Server debugging java interviews performance FIX Protocol interview questions JUnit testing WebSphere date and time tutorial experienced java IO tutorial java concurrency thread Ejb Freshers Papers IT Management Java Exapmle Java Script SQL and database tutorial examples Scwcd ant tutorials concurrency example and tutorial future state homework java changes java threading tricky Agile Business of IT Development JSTL Java JSON tutorial Java multithreading Tutorials PM Scrum data structure and algorithm java puzzles java tips testing tips windows 8 5 way to create Singleton Object Architect Interview Questions and Answers Architecture Architecure Bluetooth server as swing application that searches bluetooth device in 10 meter circle and show all devices. You can send file to any bluetooth device. C Programming CIO Callable Statement in Java Circular dependency of Objects in Java Comparable Example in Collection Custom annotation in Java Developer Interview Divide and rule example in java Drupal Example of Singleton Pattern FIX protocol ForkJoin Example in Java 7 Get data from dynamic table with Java Script Git HTML and JavaScript Health Hello World TCP Client Server Networking Program Hibernate Basics Hibernate Interview Question Answer J2EE Interview Question And Answers J2ME GUI Program JEE Interview QA JMS interview question Java J2EE Hibernate Spring Struts Interview Question Java System Property Java Threads Manager Portlets Provident Fund Read data from any file in same location and give the required result. Reading Properties File in Java Redpoint Rest WebService Client Rest Webservice Test SAL join with ven diagram SCP UNIX COMMAND SSL Singleton Pattern in Java Spring Bean Initialization methods and their order Spring Interview Questions Struts Struts 2.0 Basics Struts 2.0 Design Pattern Submit Html Form With Java Script On The Fly Unix executable For Java Program XOM DOM SAX XP books computers core java; core java; object oriented programming data structure; java investment bank; design pattern dtd duplicate rows in table get browser name with jquery grails podcast inner class java beginners tutorial java cache java networking tutorial java spring java util; java collections; java questions java.java1.5 linked list mailto function with all browser oracle database oracle duplicate rows orm schema social spring mvc questions struts transaction tricks tweet windows xslt