2

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
Antoine
  • 5,158
  • 1
  • 24
  • 37
thelittlebug
  • 137
  • 1
  • 8
  • I'm unable to reproduce this problem using Groovy 1.8.5. What version are you using ? – Antoine Mar 04 '12 at 17:17
  • 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 tag. shame on me... thank you for your time :) – thelittlebug Mar 04 '12 at 17:57
  • 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 Mar 05 '12 at 08:16
  • @thelittlebug - if this solved your problem, please either mark the question answered, or remove it. – GreyBeardedGeek Oct 17 '12 at 00:14
  • @GreyBeardedGeek - how can i mark the question as answered? – thelittlebug Oct 17 '12 at 21:14
  • You should be able to post an answer to your question, and then accept it. This will also help people looking for the answer to your question. – GreyBeardedGeek Oct 18 '12 at 01:13

1 Answers1

1

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.

Vikdor
  • 23,934
  • 10
  • 61
  • 84
thelittlebug
  • 137
  • 1
  • 8