Convert DOM to perlish object? #2101
Answered
by
Grinnz
hussam-qasem
asked this question in
Q&A
-
I have a server that returns a simple XML, e.g.: <Device id="1234">
<info name="modelid" value="omg"/>
<info name="picture" value="http://192.168.1.1/images/lol.jpg"/>
<info name="status" value="0"/>
</Device> is there a Mojo way to convert this DOM to a perlish object? Ultimately, I'd like to render a JSON. Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
Grinnz
Sep 11, 2023
Replies: 1 comment 2 replies
-
Not automatically, XML does not map to a json-like data structure. Your best option is to use Mojo::DOM and knowledge of the specific format you are receiving to translate it into an object in the structure that makes sense to you. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
hussam-qasem
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not automatically, XML does not map to a json-like data structure. Your best option is to use Mojo::DOM and knowledge of the specific format you are receiving to translate it into an object in the structure that makes sense to you.