Ignoring the fact that it doesn't seem to do what you describe, parsing stuff using terms like "word" is fraught with danger. It should probably be treated as XML and done that way, but it's the sort of thing text item delimiters makes very simple:
set theData to "<?xml version=\"1.0\"?>
[...]
</ncx>
"
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"\" playOrder=\""}
set theDataItems to text items of theData
set newData to item 1 of theDataItems
set theDataItems to rest of theDataItems
set AppleScript's text item delimiters to {"\""}
repeat with i from 1 to count of theDataItems
set newData to newData & "\" playOrder=\"" & i & "\"" & (text items 2 thru -1 of item i of theDataItems) as text
end repeat
set AppleScript's text item delimiters to oldDelims
return newData