How to iterate through xml using javascript while altering the document?

terryseastar

New Member
How can I iterate through a list of xml nodes (tag="items"), and while doing so, inserting a new node in a particular place, in this case when a chileNode value changes (tag="rowNum")? Here's an example showing my input and my desired output:Starting xml:\[code\]<items> <item> <rowNum>1</rowNum> <description>some text</description> </item> <item> <rowNum>1</rowNum> <description>some more text</description> </item> <item> <rowNum>2</rowNum> <description>some text</description> </item></items>\[/code\]Desired output:\[code\]<items> <item> <rowNum>1</rowNum> <description>some text</description> </item> <item> <rowNum>1</rowNum> <description>some more text</description> </item> <item> <rowNum>1</rowNum> <description>last row 1 item</description> </item> <item> <rowNum>2</rowNum> <description>some text</description> </item> <item> <rowNum>2</rowNum> <description>last row 2 item</description> </item></items>\[/code\]
 
Back
Top