Re: [Mojolicious] Re: Convert XML to Perl data structure with Mojo::DOM

2019-02-24 Thread Dan Book
You could of course implement it with Mojo::DOM, but the thing about
converting XML to Perl data structures is it has to be specific to the XML
you're getting. Which is why you can do it with SOAP. Trying to just
convert arbitrary XML to Perl data structures leads to XML::Simple nonsense
nightmares, because XML can contain text nodes anywhere, and any tag can
have attributes and multiple ordered contents. But with a specific
structure in mind, you can go through it with Mojo::DOM and manually map it
to the data structure you want.

-Dan

On Sun, Feb 24, 2019 at 5:19 PM Stefan Adams  wrote:

> I'm dealing with SOAP data and found that this meets my needs:
>
> $self->ua->post_p(@_)->then(sub {
>   *SOAP::Deserializer->deserialize(shift->result->dom)->result*
> });
>
>
> That generates a complex Perl data structure -- exactly what I want.  I
> reckon there's a way to re-implement this with Mojo?
>
> On Sun, Feb 24, 2019 at 11:47 AM Stefan Adams  wrote:
>
>> Is it possible to recursively convert an XML string into a Perl data
>> structure with Mojo::DOM?
>>
>> Something like:
>>
>> 
>> M1N1
>> M2N2
>> M3N3
>> 
>>
>> Into:
>>
>> {a => {x => [{m => 'M1', n => 'N1'}, {m => 'M2', n => 'N2'}], y => [{m =>
>> 'M3', n => 'N3'}]}
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mojolicious+unsubscr...@googlegroups.com.
> To post to this group, send email to mojolicious@googlegroups.com.
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Convert XML to Perl data structure with Mojo::DOM

2019-02-24 Thread Stefan Adams
I'm dealing with SOAP data and found that this meets my needs:

$self->ua->post_p(@_)->then(sub {
  *SOAP::Deserializer->deserialize(shift->result->dom)->result*
});


That generates a complex Perl data structure -- exactly what I want.  I
reckon there's a way to re-implement this with Mojo?

On Sun, Feb 24, 2019 at 11:47 AM Stefan Adams  wrote:

> Is it possible to recursively convert an XML string into a Perl data
> structure with Mojo::DOM?
>
> Something like:
>
> 
> M1N1
> M2N2
> M3N3
> 
>
> Into:
>
> {a => {x => [{m => 'M1', n => 'N1'}, {m => 'M2', n => 'N2'}], y => [{m =>
> 'M3', n => 'N3'}]}
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.