I have a issue where i need to find and replace an int within a xml file.
Here is an example file:
<?xml version="1.0" encoding="UTF-8"?>
<Data>
<Element time="0.00000" num="10723465" />
<Element time="7.98000" num="10028736" />
<Element time="8.40000" num="94123576" />
</data>
I want to find and replace the "num" attribute. I have been able to do this with the DOM
factory however it doesn't keep the order of the attributes. There must be a simpler way to find and replace the num
. any help would be great :)
Advice 1: you should use XML library to parse, nothing else, or it would be a pain.
Information 2: order doesnt matter in XML for attributes. Then you should forget this problem:
See this with much more details Order of XML attributes after DOM processing
Alternative: use Regex (it can work for very simple XML). example in the link before
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.