Results 1 to 5 of 5
  1. #1
    jackchang is offline Member
    Join Date
    Jun 2008
    Posts
    5
    Rep Power
    0

    Default JAVA and XML Problem

    Hi,

    I have a really big XML to handle (around 5000 lines).

    Basically I need to read it and pass the data to UI.

    It has a lot of tags and most of them have attributes.

    The problem is I need to pass tag names, attribute names etc... to get the data.

    If it were a small XML, i could have done it by passing the tag names and attributes names.

    Now, I want to know if i can just do something like get the root tag , get its name, check if it has children, if yes then get the tag names and text. Check if the tags have attributes. If yes, get their name and values, and so on. I can then put the tag names, tag values , attribute names, attribute values and the text values in a collection class along with the tags heirarchy wrt the root tag(0 for root, 1 for root's children, 2 for its grandchildren...) and pass it to the UI.

    Is there a way to do this?

    Thanks in advance
    Praveen

  2. #2
    Join Date
    Jan 2009
    Posts
    14
    Rep Power
    0

    Default xml parsing through all the elements

    Hi ,
    You can parse (using dom4j) the xml file each element and loop throgh all child elements like ......

    Element result = (Element) document.getRootElement();

    List resultElements = result.elements();
    if (resultElements != null && resultElements.size() != 0) {
    for (int i = 0; i < resultElements.size(); i++) {
    oneChiled= (Element) resultElements.get(i);

    etc....
    }

    You try to store all the elements received in a collection.

  3. #3
    pankaj_salwan is offline Member
    Join Date
    Jul 2008
    Location
    india
    Posts
    35
    Rep Power
    0

    Default

    JAVA Supports parser DOM to parse the xml ...

  4. #4
    Kalpesh_m is offline Member
    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0

    Default

    buddy i am creating a svg generator and have developed an gui but svg data is stored in xml format can any one help me out here

  5. #5
    Kalpesh_m is offline Member
    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0

    Smile help please urgently

    hi guys,
    i am crating a image developer whose image is stored in xml format i.e. basically a SVG creator, i have developed a basic model but i am unable to save those document in x,l format because i dont know how to use parsers of dom and basic XML component with java.
    can any one help me i am in real trouble

Similar Threads

  1. Java problem
    By grend in forum New To Java
    Replies: 5
    Last Post: 08-19-2008, 12:44 AM
  2. Problem in java
    By saytri in forum New To Java
    Replies: 4
    Last Post: 01-16-2008, 11:09 PM
  3. Problem in java
    By saytri in forum New To Java
    Replies: 6
    Last Post: 01-09-2008, 05:13 PM
  4. JAVA if problem
    By toby in forum New To Java
    Replies: 2
    Last Post: 07-25-2007, 08:58 PM
  5. java SE 6 problem
    By techlance in forum Java Applets
    Replies: 1
    Last Post: 06-28-2007, 11:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •