XML dom ..Help

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

[2009 byte] By [AmitChalwade123456a] at [2007-11-27 10:28:48]
# 1

Then after creating it you need to add it as a child of the 'source' element!

sabre150a at 2007-7-28 17:53:45 > top of Java-index,Java Essentials,Java Programming...
# 2

It is not child of source it is part of text say

<>source>amit <b>is</b>here</source>

Like that

suggeest solution for this

Thanks in advance

AmitChalwade123456a at 2007-7-28 17:53:45 > top of Java-index,Java Essentials,Java Programming...
# 3

as soon as u create a child for <source>, automatically the text node gets created in the form:

<source>

#text

<b>

#text

</b>

#text

</source>

now set node values for these text nodes as u like....

And tell us if it helps.... :)

@@CKM@@a at 2007-7-28 17:53:45 > top of Java-index,Java Essentials,Java Programming...
# 4

You mean likeElement B = xmlDoc.createElement("B");

B.appendChild(xmlDoc.createTextNode(src));

source.appendChild(B);

sabre150a at 2007-7-28 17:53:45 > top of Java-index,Java Essentials,Java Programming...
# 5

Thanks a lotsabre &&&@@CKM@@Thanks frens i solved it !!!!!!!!!!!

AmitChalwade123456a at 2007-7-28 17:53:45 > top of Java-index,Java Essentials,Java Programming...
# 6

anytime dude... have a nice time... ;)

@@CKM@@a at 2007-7-28 17:53:45 > top of Java-index,Java Essentials,Java Programming...
# 7

> Thanks a lotsabre &&&@@CKM@@Thanks frens

> i solved it !!!!!!!!!!!

Err..hrr.. - who solved it?

sabre150a at 2007-7-28 17:53:45 > top of Java-index,Java Essentials,Java Programming...
# 8

Hey u all helped me to solve it !!!!!

AmitChalwade123456a at 2007-7-28 17:53:45 > top of Java-index,Java Essentials,Java Programming...