Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

XML Parsing: How to parse 20-100kb of xml?


  • Please log in to reply
7 replies to this topic

#1 samjones

samjones

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts

Posted 25 December 2011 - 03:22 AM

Any guidance appreciated for this newb question! I have a simple .net app, running on the desktop. I am using linq and xml.linq, so life is pretty good. I want to run this on netduino, and need to figure out: - How to parse the interesting elements from an xml response that is 20kb - 100kb in size - How to do this every 60 seconds... Any pointers greatly appreciated!

#2 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 25 December 2011 - 10:14 AM

Hello SamJones, and Happy Xmas, wherever you are. I'd guess you won't able do that: consider that 100K is about the overall free RAM space of a Netduino space. Even supposing a complete parsing, you'd need enough space for the DOM... Rather, you may consider some kind of binary serialization, which *should be* the most efficient way to exchange data. However, that could be a bit complex, but may solve your problem. Cheers
Biggest fault of Netduino? It runs by electricity.

#3 samjones

samjones

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts

Posted 25 December 2011 - 05:31 PM

One idea we had was to save the xml to the sd card, then parse through it sequentially... but I don't know if the netduino cpu can do this fast, or if it will take 30 seconds or something...

#4 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 25 December 2011 - 06:20 PM

The SD is a good idea, but to achieve a sequential parsing, you should use SAX, instead of DOM. This is not available, though.
At this point, the only way is to implement your own parser...just an overkill, but it may be worthwhile, maybe.

Cheers
Biggest fault of Netduino? It runs by electricity.

#5 samjones

samjones

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts

Posted 25 December 2011 - 08:22 PM

Thanks. I am taking another route....

#6 Spork

Spork

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts

Posted 25 December 2011 - 08:43 PM

This might be a crazy suggestion, but there is a JSON parser available: netduino.helpers.Helpers.JSONParser. As is, it wouldn't solve the OP's problem, but I wonder how hard it would be to modify it so that instead of building up a data structure of Hashtables and ArrayLists it would fire off SAX-type events to a ContentHandler? Maybe I'm kidding myself, but it looks like it might be easy. I guess the result would be called "SAJ" (Simple API for JSON). Googling "SAJ Simple API for JSON" shows that at least one person has already done something like this for other platforms.

#7 samjones

samjones

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts

Posted 25 December 2011 - 09:53 PM

Interesting! I don't have control over the data format, and it is xml. I am writing a web service to make the large xml response simple.

#8 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 26 December 2011 - 12:52 AM

Interesting!
I don't have control over the data format, and it is xml.

I am writing a web service to make the large xml response simple.


I think this is very much do-able on the Netduino. I have streamed individual files from the microSD card that were in excess of 300k. And I could have easily inspected the text of the chunks. You'll have to use streams and reasonably sized chunks and parse/inspect the file as text.

-Valkyrie-MT




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.