Create a tree from XML

hi. I have created a simple XML file which contains a hierarchical structure of strings.
Also, I have created a SAXParser to read from the xml.
But I don't know how to put this structure in a JTree.I don't want to show the tree on screen. I want to be able to access certain nodes at different times.
Any help?

I've created the SAXParser and as you can see I've read the XML file. I need to write some code in the characters method to add the relecvant strings to the tree. I'm quite new at this...
public class Echo extends DefaultHandler
public static void main(String args[])
DefaultHandler handler=new Echo();
SAXParserFactory factory=SAXParserFactory.newInstance();
try
SAXParser saxParser=factory.newSAXParser();
saxParser.parse(new File("meniu.xml"),handler);
}catch(Throwable t)
t.printStackTrace();
System.exit(0);
public void startDocument()
throws SAXException
public void endDocument()
throws SAXException
public void startElement(String namespaceURI,
String sName,
String qName,
Attributes attrs)
throws SAXException
String eName=sName;
if("".equals(eName)) eName=qName;
public void endElement(String namespaceURI,
String sName,
String qName)
throws SAXException
public void characters(char[] buf,int offset, int len)
throws SAXException
String s=new String(buf,offset,len);
if(!s.trim().equals("")) {

Similar Messages

  • How to create Inbound Idoc from XML file-Need help urgently

    Hi,
    can any one tell how to create inbound Idoc from XML file.
    we have xml file in application server Ex. /usr/INT/SMS/PAYTEXT.xml'  we want to generate inbound idoc from this file.we are successfully able to generate outbound XML file from outbound Idoc by using the XML port. But not able to generate idoc from XML file by using we19 or we16.
    Please let me know the process to trigger inbound Idoc with out using  XI and any other components.
    Thanks in advance
    Dora Reddy

    Hi .. Did either of you get a result on this?
    My question is the same really .. I am testing with WE19 and it seems SAP cannot accept an XML inbound file as standard.
    I see lots of mention of using a Function Module.
    Am I correct in saying therefore that ABAP development is required to create a program to run the FM and process the idoc?
    Or is there something tht can be done with Standard SAP?
    Thanks
    Lee

  • Create Business Partner from XMl String not a file

    Hi,
    Is it possible to create a BP from an XML string. 
    I know about GetBusinessPartnerFromXml(string FileName, int index)
    but I dont want to save the string in a file before creating a BP from it
    Hope there's a method to do that

    Marc,
    This looks like it is a duplicate of this post, so I am closing this thread as it looks like you answered your own question!
    Create Business Partner from XMl String not a file
    Eddy

  • How to automatically create fillable PDFs from XML

    We are looking for a way to create fillable PDFs that users can enter data into and save (so the PDF needs Reader Rights applied) and we want to be able to automatically create these PDFs from XML files. We are able to do what we want in a manual fashion using Acrobat Pro v8 but we need a way to automate this due to the volume of XML files that we will need to convert.
    Is there any way that this can be scripted from a command line interface with Acrobat.. like:
    Acrobat.exe –input FileName.xml –output FileName.pdf –applyReaderRights true
    If there is no command line options for this is there any way that this could be coded using .NET or any other programming language?

    You cannot automate applying usage rights with Acrobat. For that you'd need to use Adobe's LiveCycle Reader Extensions.
    How exactly are you currently converting XML into fillable forms? Are you using an XDP to somehow convert to an XFA-based PDF?

  • Tree from XML (JMX monitoring and management application)

    I am trying to create a tree structure from XML. I am setting
    the below XML as the dataProvider for the tree.
    Now I only want to see the "element" labels in the tree
    structure. But I also see the operationList and the operations
    under it too. Is there any way I can filter these out from the tree
    structure ?
    The reason why I have the operations is that I have to
    display them on the right hand side, i.e whenever someone clicks on
    an element the operations corresponding to that have to be
    displayed on the right hand side.
    If you see the "flex-admin" application under the livecycle
    data services ... my applications is exactly similar to that.
    If anyone needs more information, I would be happy to
    provide.
    <?xml version="1.0" encoding="UTF-8"?>
    <centralmbeanserver>
    <element label = "FMC-DropCopies-QA" canonicalName =
    "CentralMBeanServer:App=FMC-DropCopies-QA" >
    <element label = "Cache Manager" canonicalName =
    "CentralMBeanServer:App=FMC-DropCopies-QA,Componet=Cache Manager"
    >
    <element label = "SACFixFilterRulesCache" canonicalName =
    "CentralMBeanServer:App=FMC-DropCopies-QA,Componet=Cache Manager,DB
    Cache=SACFixFilterRulesCache" >
    <operationList>
    <operation name = "reloadDBCache" returnType =
    "java.lang.String">
    </operation>
    </operationList>
    </element>
    <element label = "SACFIXExecBrokerMapCache" canonicalName
    = "CentralMBeanServer:App=FMC-DropCopies-QA,Componet=Cache
    Manager,DB Cache=SACFIXExecBrokerMapCache" >
    <operationList>
    <operation name = "reloadDBCache" returnType =
    "java.lang.String">
    </operation>
    </operationList>
    </element>
    </element>
    <element label = "Source Manager" canonicalName =
    "CentralMBeanServer:App=FMC-DropCopies-QA,Componet=Source Manager"
    >
    <operationList>
    <operation name = "enableAllMsgSources" returnType =
    "void">
    </operation>
    <operation name = "disableAllMsgSources" returnType =
    "void">
    </operation>
    <operation name = "listMsgSourceNames" returnType =
    "java.util.List">
    </operation>
    <operation name = "reloadSources" returnType = "void">
    </operation>
    </operationList>
    <element label = "CS-SACFIX6-SS" canonicalName =
    "CentralMBeanServer:App=FMC-DropCopies-QA,Componet=Source
    Manager,Msg Source=CS-SACFIX6-SS" >
    <operationList>
    <operation name = "enableMsgSource" returnType = "class
    java.lang.String">
    </operation>
    <operation name = "disableMsgSource" returnType = "class
    java.lang.String">
    </operation>
    </operationList>
    </element>
    <element label = "CS-SACFIX1-SS" canonicalName =
    "CentralMBeanServer:App=FMC-DropCopies-QA,Componet=Source
    Manager,Msg Source=CS-SACFIX1-SS" >
    <operationList>
    <operation name = "enableMsgSource" returnType = "class
    java.lang.String">
    </operation>
    <operation name = "disableMsgSource" returnType = "class
    java.lang.String">
    </operation>
    </operationList>
    </element>
    </element>
    </element>
    </centralmbeanserver>

    How is the WebSphere node connected to the cluster? Is it using TCMP? Extend?
    Local, Distributed, Replicated, Near, Overflow, External and Optimistic cache statistics appear in the Coherence JMX server. However, near and local caches created on extend nodes do not appear. Therefore the -Dtangosol.coherence.management.remote=true on an Extend client will not register the near or local caches.
    Thanks,
    Everett

  • Dynamically create Value Objects from XML file

    Hi
    I want to create a value object from Xml file dynamically,like in the xml file i have the name of the variable and the datatype of the variable.is it possible do that,if so how.

    Read about apache's Digester tool. This is part of the Jakartha project. This tool helps in creating java objects from the XML files. I am not sure, if that is what u r looking for.

  • How to create value objects from xml

    I am receiving xml back from my web service ( e4x ). I am
    trying to figure out how to create a value object without having to
    manually fetch each value in the value objects constructor. I am
    using introspecton in my Java web service to do this. Is there such
    a thing in Action Script?
    Anyone done this before that can share some code???? Any help
    would be very much appreciated.

    That's twice now I've heard that. lol.
    I am using Cairngorm and I suppose out of ignorance perhaps,
    I am using VO's. So my web service would return an Object Proxy and
    I have some code that could create objects dynamically from the
    results. The objects had to be simple of course and now they are
    becoming more complex thus the need to change to e4x instead of
    objects.
    So now I am trying to convert the xml result into the desired
    VO to be used throughout the rest of the application. I'm not sure
    how to use Cairngorm without the VO's they are tied to everything.
    Are you familiar with the architecture? Your thoughts?

  • Create java objects from xml

    I want to create a tree structure for java object. These java objects are populated after the parsing the xml. But what could be the logic for adding child to parent when there are
    many sub nodes? I wanted to use one recursive function which iterate through all the elements of the xml file. But I have not got the idea how to add one child object to parent object.
    following are my classes. Any help on this highly appreciated.
    public class TreeObject {
              private String name;
              private TreeParent parent;
              public TreeObject(String name) {
                   this.name = name;
              public String getName() {
                   return name;
              public void setParent(TreeParent parent) {
                   this.parent = parent;
              public TreeParent getParent() {
                   return parent;
              public String toString() {
                   return getName();
    import java.util.ArrayList;
    public class TreeParent extends TreeObject {
         private TreeObject treeObject ;
              private ArrayList children;
              public TreeParent(String name) {
                   super(name);
                   children = new ArrayList();
              public void addChild(TreeObject child) {
                   children.add(child);
                   child.setParent(this);
                   treeObject = child ;
              public void removeChild(TreeObject child) {
                   children.remove(child);
                   child.setParent(null);
              public TreeObject [] getChildren() {
                   return (TreeObject [])children.toArray(new TreeObject[children.size()]);
              public boolean hasChildren() {
                   return children.size()>0;
              public TreeObject getChild(){
                   return treeObject;
    private TreeParent getChilderen(Element rootNode){
         List list = rootNode.getChildren();
         String rootNodeName = rootNode.getName();
         TreeParent root = new TreeParent(rootNodeName);
         for (int i=0; i< list.size(); i++)
    Element node = (Element) list.get(i);
    if(node.getChildren().size() > 0){
         // TreeParent treeParent = new TreeParent(node.getText());
         TreeParent treesub = new TreeParent(node.getText());
         treesub.addChild(treesub);
         //TreeParent p = treeParent.getParent();
         // rootParent.addChild(treeParent);
    }else{
         TreeObject object = new TreeObject(node.getText());
         root.addChild(object);
    getChilderen(node);
         return root ;
    public TreeParent buildTree(String filePath) {
    SAXBuilder builder = new SAXBuilder();
    File xmlFile = new File(filePath);
    try{
    Document document = (Document) builder.build(xmlFile);
    Element rootNode = document.getRootElement();
    // List list = rootNode.getChildren("staff");
    TreeParent rootParent = getChilderen(rootNode);
    return rootParent ;
    }catch(IOException io){
    System.out.println(io.getMessage());
    }catch(JDOMException jdomex){
    System.out.println(jdomex.getMessage());
    return null;
    Edited by: 870611 on Jul 6, 2011 6:27 AM

    Hi
    I recommend you use the API JAXB. Is much simpler.
    here a link: http://www.oracle.com/technetwork/articles/javase/index-140168.html
    here a example: http://download.oracle.com/javaee/5/tutorial/doc/bnbay.html#bnbbc

  • Create a Database from xml

    Hi,
    I'm using javaDb embedded and I trying to find the best way to create a database from a xml file.
    I managed to do this, previously with netbeans 6.9, jdk 6 and apache ddlutils.
    Unfortunately this method as proven to be not so good, and and can't get it to work with netbeans 7.
    Is there a best way to do this?? Any recommendation on this matter will be appreciated.
    Thanks in advance,
    Hugo

    s3c wrote:
    Hi,
    I'm using javaDb embedded and I trying to find the best way to create a database from a xml file.
    I managed to do this, previously with netbeans 6.9, jdk 6 and apache ddlutils.
    Unfortunately this method as proven to be not so good, and and can't get it to work with netbeans 7.
    Is there a best way to do this?? Any recommendation on this matter will be appreciated.
    Thanks in advance,
    Hugowhat does question or solution have to do with forum TOPIC Oracle RDBMS?

  • Create a tree from a resultset

    Hi,
    I need to create a tree structure from a resultset and show them into my JSP. Here is my table sql (grup).
    CREATE TABLE GRUP (
    ID_GRUP int(11) NOT NULL default '0',
    ID_GRUP_PARENT int(11) NOT NULL default '0',
    ORDER_BY int(11) NOT NULL default '1',
    DESCRP varchar(100) default NULL,
    PRIMARY KEY ('ID_GRUP'),
    )What I really need is a recursive method to search for all the children of each row and build a tree heirarchy. e.g. the data may look like
    ID_GRUP   ID_GRUP_PARENT      ORDER_BY    DESCRP
    1               0                 1        It itself is the parent
    2               1                 1        It's Parent is ID_GRUP=1
    3               0                 2        It itself is the parent
    4               2                 1        It's parent is ID_GRUP=2
    5               1                 2        It's Parent is ID_GRUP=1
    6               4                 1        It's Parent is ID_GRUP=4
    7               2                 2        It's parent is ID_GRUP=2
    8               2                 3        It's parent is ID_GRUP=2So looking at the top data my final tree structure should look like
    1
      2
        4
          6
        7
        8
      5
    3and so on. ORDER_BY show the order in which each element should display in the heirarchy. I am really struggling to find a way on how to have the heirarchy built and really need some help.
    Thanks
    Here is the SQL i have to het the data
    SELECT ID_GRUP, ID_GRUP_PARENT, DESCRP FROM GRUP ORDER BY ORDER_BY.

    First of all, you can't make a (single) tree out of that, because apparently you have two roots.
    Anyway, one you fix the requirements, you can do this by defining a tree node type (of course), a reference to the root node, and then a temporary data structure to let you go directly to identified nodes without having to traverse the tree from the root (and thus having to know all the paths to the descendant elements). For example, in Java, a good temp data structure might be a java.util.Map<Integer, YourTreeNode>, where you'll use ID_GRUP values for the keys.

  • Create an UDO from XML file

    Hello,
    I would want to create an UDO from an XML file. But I don't see any documentation about it.
    Do you know if there is any sample or something?
    Thanks in advance

    Hi Martin,
    I don't know if this is possible as I looked at the properties of the UDO object (SAPbobsCOM.UserObjectsMD) and there are no XML methods. As with the other meta data objects, like UserTablesMD and UserFieldsMD you have SaveXML and GetAsXML, but not with UDO.
    Hope it helps,
    Adele

  • Can I create an XSD from XML data in a CLOB?

    Environment:
    Oracle 11.2.0.3 EE on Solaris.
    Very much an XML newbie so please be kind! 
    I have spent the past few days pouring through the documentation and various blogs, especially this one, but ... I need some help.
    I am trying to extract XML data stored in a CLOB and produce a flat file for the user's consumption.
    They have sent me what they think is the XSD for the XML data but when I look at the data in the CLOB I don't see the tags documented in the XSD.
    I'd like to produce an XSD based on the actual data to compare with what they've sent.
    Is this possible?
    I am able to query the XML data using the tags I see in the data using XMLTable and it's working fine.
    Any help is greatly appreciated.
    -gary

    Welcome to the XML side of the world, where you will love it and curse it, just like any other piece of technology.
    So as I understand it, the scope of your operation is to extract information from an XML file and then write that information to disk, correct?
    Some questions
    - Why is the XML stored in a CLOB instead of an XMLType column?  Without knowing the system history, it is a valid question.
    - How big are the XML?  The reason I ask this is because when the XML is stored in XMLType columns (of Object Relational structure or SECUREFILE BINARY XML format), then Oracle can parse the XML substantially easier than when it is stored as a CLOB.  If the XML is fairly small, you may see no performance difference between the two.
    The Oracle DB itself has no built in ability to generate a schema from an XML file.  In order to do that, you would need to use some third party tool that has that functionality built in.  For example, XML Spy can do this.  Other tools can as well, but that is what came to mind first as it is what I use.  The one thing to remember is that the schema it builds represents that one instance of XML.  Other instances of XML may be different and not validate against the schema you generated, but still have been valid against the unknown original schema.
    You can register the schema in the database and then use the XML to create an XMLType instance associated to the schema and then validate the XML that way.  One example can be found at XML DB FAQ and here is another example Re: XML Schema validation
    Hope that helps you continue on.

  • Creating Java file from XML data

    I have a information regarding a java file like class Name, attribute name,type, and function details in a XML file now I want to create a java file from this XML. Kindly tell me the some way to solve this problem as soon as possible.
    Thanks
    Sumit Kumar Agarwal

    So how does it take this file
    file>
    <statement>
    <name>John Dow </name>
    <address>123 Main</address>
    <phone>972-213-3434</phone>
    </statement>
    <statement>
    <name>Jane Dow </name>
    <address>345 Main</address>
    <phone>972-213-3534</phone>
    </statement>
    <statement>
    <name>Marry Dow </name>
    <address>678 Main</address>
    <phone>972-213-3435</phone>
    </statement>
    </file>
    and create these three different one?
    1.)
    <statement>
    <name>John Dow </name>
    <address>123 Main</address>
    <phone>972-213-3434</phone>
    </statement>
    2.)
    <statement>
    <name>Jane Dow </name>
    <address>345 Main</address>
    <phone>972-213-3534</phone>
    </statement>
    3.)
    <statement>
    <name>Marry Dow </name>
    <address>678 Main</address>
    <phone>972-213-3435</phone>
    </statement>
    Is it not going to just grab each element after the file tag? I'm just confused about that.

  • How to create af:tree from single database Table

    Hi,
    i want to create tree Like this: and also we can add node anywhere.
    Parent01
    ----|parent01-child01
    --------|parent01-child01-child01
    --------|parent01-child01-child02
    -------------|parent01-child01-child02-child01
    Parent02
    ----|parent02-child01
    ----|parent02-child02
    --------|parent02-child02-child01
    and for this i have created Table like this :
    Table name Treetable
    NODEID     NUMBER(38,0) --> Primary Key
    NODENAME     VARCHAR2(50 BYTE) --> This is the name will display as a node
    DESCRIPTION     VARCHAR2(255 BYTE)     
    ROOTIND     CHAR(1 BYTE) --> to decide root node
    SEQUENCENO     NUMBER(38,0)     --> order to display node
    PARENTKEY     NUMBER(38,0) -->FK (refering to NODEID(PK) of this table)
    But when i am creating tree, its showing root node for each row in the table. but my requirement is: The Row marked as ROOTIND='Y' , show that row only as Root (Example in above tree:Parent01 & Parent02 )
    any help highly appreciated :)
    Thanks
    Pratap Rudra
    Edited by: 995114 on Apr 30, 2013 2:50 PM

    Hi,
    check this http://www.oracle.com/technetwork/developer-tools/adf/learnmore/32-tree-table-from-single-vo-169174.pdf
    Frank

  • Create web pages from xml files using Servets or JSP

    I�m new in this tecnology and I have to create a web pages from information that I get from a XML files. I would like to know if there is a place where I can find examples of code or any book that could help me.

    Two places with loads of information on this:
    http://xml.apache.org
    Look at Xalan or Cocoon.
    Also, there was an article on http://www.javaworld.com on XML with JSP.

Maybe you are looking for

  • Problem with creation of the jms event generator

    hi, I have set up a weblogic workshop instance on one of my machines. It has a queue call OUT.QUEUE. The application writes message to this queue. I have set up an integration instance on another machine. I have created a Foreign JMS server to point

  • Dual PSU w/Slave cable quesiton.

    I am planning on running Tri-Sli w 3x470's. I have 2 psu's that are not upto the task of doing that and running my system. 1st PSU Corsair TX950 2nd PSU Muskin Joule 1000 So I want to run my system from the 950 and gpu's from the 1000. I know how to

  • Customer Hierarchy setup

    HI Experts, Please guide me how to setup the customer Hierarchy in system and what is the table for customer hierarchy. thanks in advance. Vivek.

  • Adobe Portfolio

    I would like to move folders and documents from one portfolio to another but have had no success. Does anyone have a procedure for this? I have tried drag and drop as well as drag and drop holding the ctrl key down.

  • LiveCache connection error

    Hi,   I am getting wrong user/Password error when I execute LC10 ---> Live Cache Monitoring transaction. Here are the installation details SAP SCM SID ---> DA0 Schema Owner ---> sapda0 Live Cache SID ---> DA0 Owner ---> sapda0 when I am filling the L