Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
| Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 16th, 2006, 06:33 AM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default need help with editing an XML file using Java

Hello all,

I guess my question is simple, but I'm not experienced enough with Java and XML.

What I want to do is read an XML file then change some of the attributes and finally output it to a file again. (if possible using the DOM Java parser)

I don't know which Java tools to use about changing the content of an XML file.

hope you know the solution,
Best,
Pesho

  #2 (permalink)  
Old June 16th, 2006, 06:35 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Why do you want to do this in Java? The tool for the job is XSLT.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #3 (permalink)  
Old June 16th, 2006, 08:13 AM
Authorized User
 
Join Date: Jun 2006
Location: boston, MA, USA.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If u dont want to use XSLT u could write a transformer in java that could change the attributes u want in the XML file and then write the required contents back to the XML file . This can be done using DOM or SAX. I have implemented a similar thing in DOM .

  #4 (permalink)  
Old January 8th, 2007, 06:33 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,
Even i am facing the same problem, If any one can provide me code to add new node to existing XML file it would be gr8.
Thanx.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing File Hind Java Basics 2 June 14th, 2006 07:04 PM
Windows Registry Editing via Java Sandz J2EE 0 February 28th, 2005 10:05 AM
How to connecting java script form to xml file ashraf Javascript How-To 1 December 10th, 2004 05:47 AM
File Editing MattLeek Javascript 4 February 18th, 2004 06:52 AM
Java Applet that can read an XML file sankar J2EE 1 December 25th, 2003 05:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.