dcsimg
Importing xml nodes from one document to another. When i do this the imported xml node's attribute values all turn to nothing!?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Glen_Drinkwater
Posted On:   Wednesday, April 17, 2002 01:30 AM

I am trying to import xml nodes from one document to another but when i use the code: NodeList list = doc2.getElementsByTagName("whatever"); Document newDoc = db.newDocument(); Element root = (Element)newDoc.createElement("rootelement"); newDoc.appendChild(root); for(int i = 0; i < list.getLength();i++){ root.appendChild(newDoc.importNode(list.item(i),true)); } the attribute values from the imported node all turn to nothing. Is there a way to get around this, or to stop it happening?? Cheers    More>>

I am trying to import xml nodes from one document to another but when i use the code:


NodeList list = doc2.getElementsByTagName("whatever");


Document newDoc = db.newDocument();


Element root = (Element)newDoc.createElement("rootelement");


newDoc.appendChild(root);


for(int i = 0; i < list.getLength();i++){


root.appendChild(newDoc.importNode(list.item(i),true));



}


the attribute values from the imported node all turn to nothing. Is there a way to get around this, or to stop it happening??


Cheers

   <<Less

Re: Importing xml nodes from one document to another. When i do this the imported xml node's attribute values all turn to nothing!?

Posted By:   Noel_Prevost  
Posted On:   Thursday, April 18, 2002 01:23 PM

Can you give an example of the xml document you are doing a getElementsByTagName on. Is it the attribute being set to null or the actual value? Lumina<?

If you wanted to get Lumina, you would need to do a list.item(i).getFirstChild().getNodeValue().



an easier way to deal with the node value would be


Node temp = list.item(i);

temp.getFirstChild().getNodeValue();


Is this on line to what you are asking?
About | Sitemap | Contact