2
votes

I have following XML that XMLSlurper is unable to parse. I think XMLSlurper thinks the xxx:yyy is some kind of namespace. Is there any chance to change this behavior?

<node>
  <application app_name="export" 
               app_data="nolocal:api_on_answer=sched_hangup +3600 40887ffe-65de-11e1-89da-e9feb0a98acf alloted_timeout" 
               app_stamp="1330854103808996">
  </application>
</node>

I cannot change the XML. The error i get:

The prefix "nolocal" for element "nolocal:api_on_answer" is not bound.. Stacktrace follows:
Message: The prefix "nolocal" for element "nolocal:api_on_answer" is not bound.
Line | Method
->>   48 | doCall    in sipsy.admin.WebapiController$_closure4$$ENQh9JnT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run       in java.lang.Thread
1
I'm unable to reproduce this problem using Groovy 1.8.5. What version are you using ? - Antoine
Sry, my fault (as usual :D). I've worked with the wrong data. There are 2 xml strings, the one i've posted and a similiar one, with a <nolocal:api_on_answer> tag. shame on me... thank you for your time :) - thelittlebug
Just to be complete: If you need to parse not 100% valid XML, you can pass 2 booleans to the constructor of XmlSlurper(a, b). A is for validation and b for namespace awareness. - thelittlebug
@thelittlebug - if this solved your problem, please either mark the question answered, or remove it. - GreyBeardedGeek
@GreyBeardedGeek - how can i mark the question as answered? - thelittlebug

1 Answers

1
votes

Sorry, my fault (as usual :D). I've worked with the wrong data. There are 2 xml strings, the one i've posted and a similiar one, with a tag. shame on me... thank you for your time :)

Just to be complete: If you need to parse not 100% valid XML, you can pass 2 booleans to the constructor of XmlSlurper(a, b). A is for validation and b for namespace awareness.