Shop OBEX P1 Docs P2 Docs Learn Events
Debugging XML? — Parallax Forums

Debugging XML?

BobbyVBobbyV Posts: 19
edited 2012-02-07 19:13 in Propeller 1
Hello All,

I'v got a question for all the machine control experts out there!
I'm trying to get the propeller to talk to a piece of equipment over a standard serial interface (9600bps, 8bits, no parity, 1 stop bit) and in the manual it states that....

"The configuration grammar used to communicate with the LI-840A is based upon a subset of
the eXtensible Markup Language (XML). XML relies on the use of tags to "Markup", or give
structural rules to a set of data."


a provided example command to query for a sample of data is:
<LI840><CFG>?</CFG></LI840>

So to send this via the propeller using FullDuplexSerial I would just use a command like this:

debug.str(string("<LI840><CFG>?</CFG></LI840>"))

Correct?

The reason I'm asking this is because when did a good ol' google search on XML to serial or to "serialize XML" all I found was a bunch of really long looking C scripts to do something that I initially thought would only require one line of code! Having dealt with the frustration of getting one machine to talk to another for the first time before, I figured I would go ahead and ask now before I end up elbows deep in coffee and gummy bears!
Thanks!

Comments

  • Heater.Heater. Posts: 21,230
    edited 2012-02-01 14:54
    I think you are right in your assumption. Just send that string.
    I guess there is a bunch of other tags for different data items you can set or query in the device.
    More tricky might be the translation of the returned xml into data values. As you have to parse those tags to see what you have got.
    I guess searching for "serializing xml" or such does not turn up much because the XML is already serial, just a bunch of characters in a string. What really happens is that your data structures get serialized to XML and XML gets deserialized into your data structure. Often producing what is call the Document Object Model, DOM, in memory.
    Hopefuly your case will be quite simple. Just send some likely looking commands to your gadget and see how and it answers.
  • gclousegclouse Posts: 5
    edited 2012-02-07 14:26
    In XML-speak, serialization means "convert some multi-dimension array or database into XML".

    I think you are on the right track.
  • Martin_HMartin_H Posts: 4,051
    edited 2012-02-07 19:13
    For simple xml documents what you are doing works fine. The reason xml parsers and generators exist is that xml has a few gotchas that you can run into with character escaping for &, ", ', <, and >. Plus they ensure that your xml is well formed.
Sign In or Register to comment.