This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes compare text contents of xml element and add child element to a particular node in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "compare text contents of xml element and add child element to a particular node in Java" Watch "compare text contents of xml element and add child element to a particular node in Java" New topic
Author

compare text contents of xml element and add child element to a particular node in Java

sarah sainy
Greenhorn

Joined: Oct 18, 2013
Posts: 23
i have an arraylist which contains title and fullname in the following format



First i am splitting the contents with |.I will get the title and fullnames. Then i split fullnames with space to get firstname and familyname.

Now i have 3 strings



The next task is i have check the text contents of existed xml with the above strings firstname and familyname.Here is the existed xml



if the
firstname
and
familyname
contets matches with the text content of above xml elements
<firstname>,<familyname>
then
i have to create on element named
<title>
and append the corresponding title from my list.

I have tried with the following code,




How to get the children and check for text contents?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38045
    
  22
Sounds too difficult for us who are “beginning”, so I shall try moving it to our XML forum.

I think you are parsing the contents of the list correctly, so you need to parse the XML. Are the entries in the List and the XML in the same order? Why do you have the data in those two places in the first place?
Ravi Khadgi
Greenhorn

Joined: Aug 06, 2010
Posts: 20

Following APIs should helpful:

- Create a new node
Document.createElement

- Create a text node
Document.createTextNode

- Insert a node inside another node
Node.appendChild
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compare text contents of xml element and add child element to a particular node in Java
 
Similar Threads
Convert text file into XML
help with web service to display xml file contents using netbeans
Performance Problem Searching Equally Named Nodes In Two XMLs
parsing data and storing in the xml
Need assistance with JSONJAXBContext ("...Content is not allowed in prolog")