Results 1 to 2 of 2
  1. #1
    dottbin is offline Member
    Join Date
    Apr 2011
    Posts
    8
    Rep Power
    0

    Default JDOM how to insert Element:HELP!!!

    hi all,
    I created following code:
    Java Code:
    Namespace xmlns = Namespace.getNamespace("configData.xsd");
                Namespace xn = Namespace.getNamespace("xn","genericNrm.xsd");
                Namespace un = Namespace.getNamespace("un","utranNrm.xsd");
                Namespace gn = Namespace.getNamespace("gn","geranNrm.xsd");
                Namespace es = Namespace.getNamespace("es","SpecificAttributes.10.22");
                Namespace xsi = Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");
               
                Element root = new Element("bulkCmConfigDataFile");
                 //insert namespace
                root.setNamespace(Namespace.getNamespace( "configData.xsd" ));
                root.addNamespaceDeclaration(xn);
                root.addNamespaceDeclaration(un);
                root.addNamespaceDeclaration(gn);
                root.addNamespaceDeclaration(es);
                root.addNamespaceDeclaration(xsi);
    
    root.addContent(new Element("fileHeader",Namespace.getNamespace( "configData.xsd" )).setAttribute("fileFormatVersion", "32.615 V4.5").setAttribute("vendorName", "VENDOR")
            .addContent(new Element("configData",Namespace.getNamespace( "configData.xsd" )).
                addContent(new Element("SubNetwork",xn).setAttribute("id", "Italia_R").
                    addContent(new Element("userDefinedNetworkType",xn).addContent("UTRAN")).
                    addContent(new Element("SubNetwork",xn).setAttribute("id", "NAERNC0236")))));
    
    List<Element> a = new ArrayList<Element>();
    ElementFilter eFilter = new ElementFilter("SubNetwork", xn);
    
    Iterator elementList=root.getDescendants(eFilter);
    
    while (elementList.hasNext()) {
        System.out.print(elementList.hasNext());
    Element nextElement = (Element) elementList.next();
    System.out.print(nextElement);
    a.add(nextElement);
            }
    for (Element el : a){
        el.addContent(new Element("hello",es));
        
    }
    
    XMLOutputter outputter = new XMLOutputter();
    outputter.setFormat((outputter.getFormat().getPrettyFormat()));
    I would like to insert child Element("hello",es) when Element("SubNetwork",xn) is found on Element root.
    But Java generates following error:
    Java Code:
    java.util.ConcurrentModificationException
    How can I solve this issue?

    Thx in advanced

  2. #2
    dottbin is offline Member
    Join Date
    Apr 2011
    Posts
    8
    Rep Power
    0

    Default

    My code works fine :D
    I forgot to delete a command line :p

Similar Threads

  1. jdom question , show xml
    By pipikrk in forum New To Java
    Replies: 11
    Last Post: 05-05-2010, 02:20 PM
  2. Replies: 4
    Last Post: 02-18-2010, 04:24 PM
  3. XML JDOM XPATH NumberFormatException
    By Jazzperson in forum Advanced Java
    Replies: 3
    Last Post: 03-08-2009, 08:15 PM
  4. Replies: 3
    Last Post: 02-28-2009, 09:17 AM
  5. JDOM in java applications
    By boy22 in forum Advanced Java
    Replies: 1
    Last Post: 08-02-2007, 05:38 PM

Posting Permissions

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