Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 29th, 2003, 06:49 AM
Registered User
 
Join Date: Dec 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to use the xml and XSLT to create a Tree struc

Please Help me related to this

Is it possible too create a treestructure which will be pick from the xml file.
Please reply me back

Please send me code
Regards
Umesha Y.K

 
Old December 29th, 2003, 08:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti
Default

Quote:
quote:Originally posted by umeshayk
 Please Help me related to this

Is it possible too create a treestructure which will be pick from the xml file.
Please reply me back

Please send me code
Regards
Umesha Y.K

Yes of course. You can use JAXP:

Code:
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import java.io.File;

public class ParseXML {
  public static void main(String[] args)
  {
    if(args.length != 1 || args[0] == null || args[0].trim().equals("")) {
      System.out.println("Invalid argument!");
      System.exit(1);
    }
    try {
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      // we suppose that the URI of the XML document is in the args[0] 
      Document xmlDocument = db.parse(new File(args[0]));
      // variable xmlDocument contains the DOM tree (the root node) 
      // process the DOM tree here
      // ...
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}
Regards,
Armen





Similar Threads
Thread Thread Starter Forum Replies Last Post
tree xml to flat xml whiteadi XSLT 2 November 14th, 2006 02:36 PM
Flat XML structure to a tree by XSLT Borg0011 XSLT 2 July 9th, 2006 08:58 AM
Create a tree structure in visual C++ limkimh88 C++ Programming 7 June 22nd, 2006 11:14 PM
Transforming a result tree with yet another Xslt ballo XSLT 2 March 7th, 2006 09:42 AM
Problem applying simple XSLT to XML to create CSV gregclark XSLT 2 August 25th, 2005 07:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.