Error from ImportXML

Posted by Ksajal on Tue 04 May 2010 09:15 PM — 6 posts, 22,420 views.

#0
This is really weird, I am trying to import a trigger and I can't seem to get to the bottom of this error:

Line   44: Element name must start with letter or underscore, but starts with "3" (problem in this file)

I've defined the trigger in Mushclient first (triggers -> add), copied it, then pasted in the file I am trying to load it from.
Here's how it looks when I paste it directly from mush:

<triggers>
  <trigger
   group="System_Pipel"
   match="^Total Pipes\: (\d+)$"
   name="pipes_assign"
   regexp="y"
   send_to="12"
   sequence="100"
  >
<!--the line below is the troublesome line-->
  <send>if (tonumber("%1")&lt;3) then
&#9;display.warning("not enough pipes")
else
&#9;pipes:assign()
end--if
EnableTriggerGroup("System_Pipel", false)
</send>
  </trigger>
</triggers>

I've deleted the weird symbols (and replaced the one near "3" with "<") and this is how it looks after that:

  <trigger
   group="System_Pipel"
   match="^Total Pipes\: (\d+)$"
   name="pipes_assign"
   regexp="y"
   send_to="12"
   sequence="100"
  >
<!--the line below is the troublesome line-->
  <send>if (tonumber ("%1")<3) then
display.warning("not enough pipes")
else
pipes:assign()
end--if
EnableTriggerGroup("System_Pipel", false)</send>
  </trigger>

Can anyone please tell me what is wrong it it?
USA #1
&lt; is the XML 'entity' for <, a bit like an escape sequence. Just like you can't have " on its own in a lua string ("I say "this""), you can't have < on its own in an XML document. I changed the < to &lt; in your second snippet and it worked fine.

I think the &#9; comes from you using the TAB key in your code (because the TAB character has ASCII code 9). It shouldn't hurt anything by being there though, because it should be translated back to a TAB character when MUSHclient loads the XML. (Just like how &lt; is turned back into < when it's loaded.)


EDIT: I had to add <triggers></triggers> around the second snippet too. You seem to have removed that compared to the first snippet.

EDIT 2: I copied the first snippet and Imported it without making any changes, and it worked fine. Are you just bothered by the weird symbols? :)
Amended on Tue 04 May 2010 09:34 PM by Twisol
Australia Forum Administrator #2
Ksajal said:


I've deleted the weird symbols (and replaced the one near "3" with "<") ...



I don't understand the problem here. What you pasted (the first one) can be imported back in (by hitting the paste button in the trigger list). Naturally if you change it, you will have problems.

Also, ImportXML works fine too:


ImportXML [[
<triggers>
  <trigger
   group="System_Pipel"
   match="^Total Pipes\: (\d+)$"
   name="pipes_assign"
   regexp="y"
   send_to="12"
   sequence="100"
  >
<!--the line below is the troublesome line-->
  <send>if (tonumber("%1")&lt;3) then
&#9;display.warning("not enough pipes")
else
&#9;pipes:assign()
end--if
EnableTriggerGroup("System_Pipel", false)
</send>
  </trigger>
</triggers>
]]


As Twisol said, since it is using <xxx> for XML entities, it has to change any "<" symbols in your code to &lt; - the same as in an XML document. So, leave them as is.

If that troubles you, use the addxml module. Read about it here:

Template:post=7123
Please see the forum thread: http://gammon.com.au/forum/?id=7123.
USA #3
Nick Gammon said:
If that troubles you, use the addxml module. Read about it here:

(post=7123)


*cough* Or Reflex! *cough*

Template:post=10073
Please see the forum thread: http://gammon.com.au/forum/?id=10073.
#4
I've tried using it exactly as it was pasted from mushclient, and it worked.

Thanks for the help!

EDIT: yes, Twisol, it kind of bothered me a bit because I didn't know what it was. Now I do!
Amended on Wed 05 May 2010 12:15 PM by Ksajal
USA #5
Ksajal said:

I've tried using it exactly as it was pasted from mushclient, and it worked.

Thanks for the help!

EDIT: yes, Twisol, it kind of bothered me a bit because I didn't know what it was. Now I do!


No worries. :) Glad you got it sorted.