This discussion is archived
8 Replies Latest reply: Jul 13, 2007 4:39 AM by 807605 RSS

XML dom  ..Help

807605 Newbie
Currently Being Moderated
I am creating one xml file in java.
  public Document createXml(String Error,String src,String trg)
  {
        DocumentBuilderFactory docBuilderFactory = null;
       DocumentBuilder docBuilder = null;
        
        try {
             
             docBuilderFactory = DocumentBuilderFactory.newInstance();
             docBuilder = docBuilderFactory.newDocumentBuilder();
             xmlDoc = docBuilder.newDocument();
            //create the root element
            Element errorLog = xmlDoc.createElement("errorLog");
            //all it to the xml tree
              xmlDoc.appendChild(errorLog);
              
             
                   Element error = xmlDoc.createElement("error");
                    error.setAttribute("Type",Error);
                    errorLog.appendChild(error);
                    
                    Element source = xmlDoc.createElement("source");
                   Element B = xmlDoc.createElement("B");
                    
                    source.appendChild(xmlDoc.createTextNode(src));
                    error.appendChild(source);
                    Element target = xmlDoc.createElement("target");
                    target.appendChild(xmlDoc.createTextNode(trg));
                    error.appendChild(target);
              
              
             
        } catch (Exception ex) {
             
        }
        return xmlDoc;
              
   }
In this I want to put <b></b> this tag inside text of <source ></source>
Now xml doc looks like

?xml version="1.0"?>
<errorLog>
<error Type="Errror"/>
<source>amit is here</source>
<target></target>
</error>
</errorLog>
I want bold tag inside text of source

Help