Technology Programming

Tutorial for SDK Java XML

    • 1). Open your Java Eclipse editor from the Windows program menu. Open the Web or desktop project you want to use to import the XML data.

    • 2). Open the XML file. Use the following code to open an XML data file:

      File file= new File("c:\\myfile.xml");

      Replace "myfile.xml" with the name of the XML file you want to parse.

    • 3). Create the "builder" class variables that parse the data. The Java SDK automatically parse the XML in the file, so you can extract the information without parsing tags from the actual data. Add the following code to use the Java XML parser:

      DocumentBuilderFactory builder = DocumentBuilderFactory.newInstance();
      DocumentBuilder parser = builder.newDocumentBuilder();
      Document xmldoc= parser.parse(file);
      xmldoc.getDocumentElement().normalize();

    • 4). Import the data. With the XML document parsed, you can import the data. For instance, the following code retrieves the first node and displays the data to the user:

      string root = xmldoc.getDocumentElement().getNodeName();
      NodeList customers = xmldoc.getElementsByTagName("customer");
      Node node1= customers.item(0);
      System.out.println("Root Node Name : " + root);
      System.out.println("Customer Name : " + getTagValue("name", node1));

SHARE
RELATED POSTS on "Technology"
WordPress - How to Set up a New Theme to WordPress 3.
WordPress - How to Set up a New Theme to WordPress 3.
Solution of Creative Web Design
Solution of Creative Web Design
The three disciplines of User Experience
The three disciplines of User Experience
Web Design Sheffield Options For Professional Enterprises
Web Design Sheffield Options For Professional Enterprises
Do you have what it takes?
Do you have what it takes?
Segway Cost
Segway Cost
Microsoft Access 2010: What's Coming with Office 2010?
Microsoft Access 2010: What's Coming with Office 2010?
Companies of Web Development in Ireland Provide Designs that Work
Companies of Web Development in Ireland Provide Designs that Work
Penguin Update to Put Red-Flags on Negative SEO
Penguin Update to Put Red-Flags on Negative SEO
Innovative web 2 design templates can make your business famous quickly
Innovative web 2 design templates can make your business famous quickly
Building A Search Engine Friendly Website
Building A Search Engine Friendly Website
Exceptional Advice To Build Up Your Internet Marketing
Exceptional Advice To Build Up Your Internet Marketing
The Benefits of Selecting The Right Hosting Company
The Benefits of Selecting The Right Hosting Company
Is There a Methodology for Making Successful Logos
Is There a Methodology for Making Successful Logos
Benefits of Ruby On Rails Development
Benefits of Ruby On Rails Development
The Power of Colour and Shapes in Your Infant's Life.
The Power of Colour and Shapes in Your Infant's Life.
Advantages of Hiring PSD To HTML Service Providers
Advantages of Hiring PSD To HTML Service Providers
How to Make Responsive Web Design Attractive?
How to Make Responsive Web Design Attractive?
Converting PSD to Responsive HTML
Converting PSD to Responsive HTML
Just a few realy really hints and tips when it comes to website design but look for.
Just a few realy really hints and tips when it comes to website design but look for.

Leave Your Reply

*