• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 20
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Following APIs should helpful:

- Create a new node
Document.createElement

- Create a text node
Document.createTextNode

- Insert a node inside another node
Node.appendChild
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic