Results 1 to 6 of 6
  1. #1
    bonjovi4u is offline Member
    Join Date
    Mar 2010
    Posts
    28
    Rep Power
    0

    Default problem wrinting into xml file...

    hi pals,

    i have a thread which creates nodes for the the document now the problem is tat when i try to supply document object into

    DOMSource source = new DOMSource(document);
    StreamResult result = new StreamResult(System.out);
    transformer.transform(source, result);

    this does not gives me xml code while the thread is running as i stop the application

    i get only the following output.....


    <?xml version="1.0" encoding="UTF-8" standalone="no"?>


    which i think means that DOMsource could not read document object while the thread is in running state!

    can any one help me out to solve this problem??

  2. #2
    nitinverma is offline Member
    Join Date
    Mar 2010
    Location
    New Delhi,Vadodara
    Posts
    50
    Rep Power
    0

    Thumbs up

    First Create file With FileConnection Object
    Then call this code.
    This is Working for me.
    U have to made Some Channges with Ur Requirment. Ok.
    public void createXmlTree(Document doc,String userid,String passwd) throws Exception
    {
    Element root=doc.createElement("user");
    doc.appendChild(root);

    Element child1=doc.createElement("UserID");
    root.appendChild(child1);
    Text text=doc.createTextNode(userid);
    child1.appendChild(text);

    Element ele=doc.createElement("Password");
    root.appendChild(ele);
    Text text1=doc.createTextNode(passwd);
    ele.appendChild(text1);

    TransformerFactory tf=TransformerFactory.newInstance();
    Transformer trans=tf.newTransformer();
    trans.setOutputProperty(OutputKeys.INDENT, "yes");
    StringWriter sw=new StringWriter();
    StreamResult result=new StreamResult(sw);
    DOMSource dom=new DOMSource(doc);
    trans.transform(dom, result);
    String xmlString=sw.toString();

    BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
    bw.write(xmlString);
    bw.flush();
    bw.close();
    }

  3. #3
    bonjovi4u is offline Member
    Join Date
    Mar 2010
    Posts
    28
    Rep Power
    0

    Exclamation

    after foing through google i have found that there are 2 ways to create Document object!!!


    first way

    DocumentBuilderFactory documentBuilderFactory=DcumentBuilderFactory.newIn stance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document document = documentBuilder.newDocument();

    (I have used this method for creating Document object.....)


    Second way

    Document document = (Document) Class.forName("com.ibm.xml.dom.DocumentImpl").newI nstance();

    (And now when i try this one i am returned with the following error[java.lang.ClassNotFoundException: com.ibm.xml.dom.DocumentImpl] which means in the first method "DocumentImpl" is not found and i cannot make out wat is the problem behind it)

    document's object is being created within a thread i have tried putting "Synchronized" too still during debugging i dont find y "DocumentImpl" is missing!!!

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default

    ClassNotFoundException: com.ibm.xml.dom.DocumentImpl]
    Is there a missing jar file that has this class?

  5. #5
    bonjovi4u is offline Member
    Join Date
    Mar 2010
    Posts
    28
    Rep Power
    0

    Default

    can any thing be done or an any onw tell me where to get this jar file from?

  6. #6
    nitinverma is offline Member
    Join Date
    Mar 2010
    Location
    New Delhi,Vadodara
    Posts
    50
    Rep Power
    0

Similar Threads

  1. jar file problem
    By abhijit in forum New To Java
    Replies: 12
    Last Post: 02-12-2010, 09:06 AM
  2. Jar File Problem
    By Moncleared in forum New To Java
    Replies: 10
    Last Post: 10-18-2009, 07:43 AM
  3. jar file problem
    By nishant.4545 in forum New To Java
    Replies: 1
    Last Post: 07-03-2009, 08:36 PM
  4. problem - using a jar file
    By jon80 in forum New To Java
    Replies: 6
    Last Post: 07-07-2008, 07:49 AM
  5. problem with jar file pls help
    By jinu5 in forum New To Java
    Replies: 0
    Last Post: 08-15-2007, 10:41 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
  •