Reputation: 1973
So I have a xml document loaded in JavaScript variable.
Xml looks like this:
<root>
<pp>test<ii>sample italic</ii> text after italic</pp>
</root>
Then I have an input box where the content of <pp>
element is written out.
Like this: test<ii>sample italic</ii> text after italic
Note that text in input box contains Xml tags.
User can then change the text in input box.
Like so: test<ii>sample BB italic</ii> and <bb>bold </bb> text after
Now I need to save this modified text back to Xml variable.
How do I do that?
EDIT 1
Question has nothing to do with saving to actual file. I just need to save/change modified data back to Xml variable.
Upvotes: 0
Views: 1246
Reputation: 2654
Maybe you could look at this link it would probably help you : http://www.ehow.com/how_5933380_change-values-xml-javascript.html
Or here, those are two goo tutorial : http://www.devguru.com/features/tutorials/xml_javascript/xml_javascript.asp
Are you reading your xml from a file ?
To create a node :
var theNewParagraph = document.createElement('p'); var theTextOfTheParagraph = document.createTextNode('Some content.'); theNewParagraph.appendChild(theTextOfTheParagraph); document.getElementById('someElementId').appendChild(theNewParagraph);
Taken from this : http://www.howtocreate.co.uk/tutorials/javascript/dombasics
Upvotes: 1
Reputation: 40448
You will need to send the data via Ajax to a server-side script, that handles the rewriting of the file. Client-side Javascript cannot solve this problem.
Upvotes: 0