Results 1 to 8 of 8
- 07-04-2008, 07:27 AM #1
Member
- Join Date
- Jul 2008
- Location
- india
- Posts
- 35
- Rep Power
- 0
- 07-04-2008, 07:32 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yes you can. Use the setTextContent() on the specific node you need.
- 07-04-2008, 07:36 AM #3
Member
- Join Date
- Jul 2008
- Location
- india
- Posts
- 35
- Rep Power
- 0
that is to set the String..bt how to replace that string with other string..
can u tel me thru certain code...Last edited by pankaj_salwan; 07-04-2008 at 07:45 AM.
- 07-04-2008, 07:47 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Here is a simple code segment. Replace with appropriate values relevant to your code.
Haven't test it. There can be spelling error. It should work, have a try.Java Code:// Use the xpath as follows XPath myXPath = XPathFactory.newInstance().newXPath(); XPathExpression myExpression = myXPath.compile("//title"); // Get the node Node myNode = (Node)myExpresion.evaluate(document, XPathConstants.NODE); // Update the text with your value myNode.setTextContent("hisssss");
- 07-04-2008, 07:51 AM #5
Member
- Join Date
- Jul 2008
- Location
- india
- Posts
- 35
- Rep Power
- 0
ok thanks...now tell me can i write the updated XML to a file..if yes then how???
- 07-04-2008, 08:00 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What you mean? That above code update the xml file, so??
- 07-04-2008, 08:04 AM #7
Member
- Join Date
- Jul 2008
- Location
- india
- Posts
- 35
- Rep Power
- 0
yeah!! it updates but i have to write the updated file sm where as a new file..
- 07-04-2008, 08:12 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Read the whole file get into a buffered reader and write back to a new file. Do it as simple file read/write process.
Similar Threads
-
JPanel won't update
By ibanez270dx in forum New To JavaReplies: 3Last Post: 01-06-2009, 08:59 PM -
[SOLVED] Update an XML file
By Eranga in forum Advanced JavaReplies: 4Last Post: 07-15-2008, 02:03 PM -
Update a record in Random access file
By Rgfirefly24 in forum New To JavaReplies: 2Last Post: 04-24-2008, 10:07 PM -
Using sql:update tag
By Java Tip in forum Java TipReplies: 0Last Post: 01-13-2008, 11:49 PM -
Read a string from a txt file
By cachi in forum Java AppletsReplies: 1Last Post: 08-07-2007, 07:50 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks