adding values to xml

Reply

Join Date: Nov 2007
Posts: 84
Reputation: knowledgelover is an unknown quantity at this point 
Solved Threads: 0
knowledgelover knowledgelover is offline Offline
Junior Poster in Training

adding values to xml

 
0
  #1
Jul 28th, 2009
hi there,
how can I change string to xml and vise verse in java, in addition how can I add values to xml according to element name ,
I can imagine something like "setValue(elementName, the value) ; as we are using in java,

any suggestions any help , please!
thanks in advance
there's always something to learn
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,609
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 464
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: adding values to xml

 
0
  #2
Jul 28th, 2009
You might want to look into the Java XML API, W3C DOM API and its implementations like Xerces. The Xerces XML parsing library comes bundled with your Java runtime. A simple Xerces program:
  1. public class Test {
  2.  
  3. public static void main(final String[] args) throws Exception {
  4. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  5. DocumentBuilder builder = factory.newDocumentBuilder();
  6. System.out.println(factory + "\n" + builder);
  7. InputSource in = new InputSource(new StringReader(
  8. "<?xml version='1.0'?><root><child value='1'/></root>"));
  9. // The doc now contains the entire XML hierarchy
  10. Document doc = builder.parse(in);
  11. }
  12.  
  13. }
BTW, if all you need to do is manipulate your XML files in memory, go for a Java specific solution like JDOM.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 84
Reputation: knowledgelover is an unknown quantity at this point 
Solved Threads: 0
knowledgelover knowledgelover is offline Offline
Junior Poster in Training

Re: adding values to xml

 
0
  #3
Jul 28th, 2009
hi,
thank you very much, I am giving it a try
there's always something to learn
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC