• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

How to add Attributes to a existing XML File.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends,
This is Palash from India says hello to u all.
In between days i am doing on XML & java.
i have some problem...
can u tell me How can i add an Atttribute to my existing
XML file...
i am able to read values from XML file but not able to modify or add.
please reply if possible...
Palash
HYDERABAD,INDIA
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi palash,
am also new in XML.
Okay i guess DOM provides a way to insert an attribute.
So read in ur xml document using a dom parser.
org.w3c.dom.Element interface has a setAttribute()/ setAttributeNode() methods for the same. SO i guess u can add one when u encounter the element of your choice.
I hope Ajit/map/ someone w'd correct me if i'm wrong.
rgds
karthik.
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"palash",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I remember that only XmlDocument can actually write to a output file. here is the api link: http://java.sun.com/xml/jaxp-1.0.1/docs/api/internal/com/sun/xml/tree/XmlDocument.html
it is in jaxp package, you may need to download the jar file from sun
 
A wop bop a lu bob a womp bam boom. Tutti frutti ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic