Replies: 1 comment 3 replies
-
I can't help with the stream vs string issue, but ThunderEX/uxml2dict: xmltodict on micropython seems to provide a more humane XML parser than xmltok. Its example code is missing a test XML file, so I saved the first example from - SVG: Scalable Vector Graphics | MDN as {"svg": {"@viewBox": "0 0 240 80", "@xmlns": "http://www.w3.org/2000/svg", "style": {"#text": ".small {\n font: italic 13px sans-serif;\n }\n .heavy {\n font: bold 30px sans-serif;\n }\n\n /* Note that the color of the text is set with the *\n * fill property, the color property is for HTML only */\n .Rrrrr {\n font: italic 40px serif;\n fill: red;\n }\n "}, "text": [{"@x": "20", "@y": "35", "@class": "small", "#text": "My"}, {"@x": "40", "@y": "35", "@class": "heavy", "#text": "cat"}, {"@x": "55", "@y": "55", "@class": "small", "#text": "is"}, {"@x": "65", "@y": "55", "@class": "Rrrrr", "#text": "Grumpy!"}]}} I could work with this structure more easily than writing a low-level parser with xmltok. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I try to parse xml data received by requests module.
I found xmltok. But it seems to expect a file-like object instead of a string.
The requests module has this stream option together with raw-results. But there goes something wrong with the encoding.
Do you have any Tips on what i should focus on?
Beta Was this translation helpful? Give feedback.
All reactions