JAVA/XML: searching and replacing a node
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Fred_Drake
Posted On:   Sunday, June 30, 2002 08:24 AM

I have two xml files A and B.

I would like to put the content of B into A, by searching in A a particular node using the value of an attribute and replacing the node with the content of B, and then save A in xml format.

How can I do that ?

Where can I find some source code sample about that ?
Thanks.

Re: JAVA/XML: searching and replacing a node

Posted By:   irfan_mansha  
Posted On:   Thursday, July 4, 2002 03:14 AM

The ever best soultion of this problem is XPath. XPath is an expression language like SQL for RDBMS. Java XML Pack supports XPath.

An XPath sample query is as follows:



college/students/student[@id="1"]


this query contains parent child relationship like XML Doc contains. It will retrieve the information of that student who has 1 as his id in XML Doc.



www.java.sun.com/xml is best source for this solution.



take care,


irfan mansha.
About | Sitemap | Contact