1

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 :)

Hiro_Hamada
  • 128
  • 2
  • 10
Grbe1l
  • 429
  • 4
  • 15

1 Answers1

1

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

Community
  • 1
  • 1