Results 1 to 4 of 4
- 05-12-2011, 04:10 PM #1
Member
- Join Date
- Feb 2008
- Posts
- 22
- Rep Power
- 0
Replace an Xml attribute/element value via Java
Hi,
I've the XML content as String. I need to search for a name (which can be an attribute name or element name) and need to replace the value of it.
Currently i'm using regular expression to find the tag and replacing it. The problem is it is taking more time.
Even the XPATH api takes more time to process and set the value.
I thought of using SAX parser but not sure how to set the value.
Can anyone please help me on this?
Thanks,
Kathir
-
As far as I understand it, SAX is an API for XML parsing, not for XML writing. Anyone, please correct me if this is wrong.
- 05-12-2011, 04:53 PM #3
Member
- Join Date
- Feb 2008
- Posts
- 22
- Rep Power
- 0
Fubarable...what is the best way to achieve the above.
-
I don't know. If you're only changing the text in some nodes, then perhaps you can do this with SAX, either writing the unchanged text as it's read in, or writing out the changed text if the appropriate node is identified. But I don't think it would be easy to change the structure of the XML via SAX.
But a warning: I'm no XML expert.
Similar Threads
-
Listing available xml element and attribute from an xsd
By lreenaers in forum XMLReplies: 3Last Post: 03-29-2010, 11:22 AM -
is there anyway to replace java.IO
By nobody58 in forum Advanced JavaReplies: 1Last Post: 03-19-2010, 02:19 PM -
Java XML DOM/Transformer and attribute ordering
By BeMathis in forum Advanced JavaReplies: 0Last Post: 10-14-2009, 07:49 PM -
Send object via web service, with a java.sql.Timestamp attribute
By diegofsza in forum Enterprise JavaBeans (EJB)Replies: 0Last Post: 08-16-2009, 12:40 AM -
Invalid usebean class attribute - new to java
By grinsalot in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 07-04-2008, 05:54 AM
Bookmarks