Problem with XMLin data structure.

V

vamsee.2005

<response status="sucess">
<value type="hash">
<item key="asdfas" value="hello"/>
<item key="adfa" value="hi"/>
</value>
</response>

XMLin is producing following below data structure from the above xml.

$VAR1 = {
'value' => {
'item' => {
'adfa' => {
'value' => 'hi'
},
'asdfas' => {
'value' => 'hello'
}
},
'type' => 'hash'
},
'status' => 'sucess'
};

What to do inorder to XMLin to force create the below datastructure.

$VAR1 = {
'value' => {
'item' => [
{ 'key' =>'adfa'
'value' => 'hi'
},
{ 'key'=> 'asdfas'
'value' => 'hello'
}
],
'type' => 'hash'
},
'status' => 'sucess'
};

Thanks, waiting for reply.
 
J

John Bokma

<response status="sucess">
<value type="hash">
<item key="asdfas" value="hello"/>
<item key="adfa" value="hi"/>
</value>
</response>

XMLin is producing following below data structure from the above xml.
[..]

What to do inorder to XMLin to force create the below datastructure.

Name the module you use instead of a method of this module. Not everybody
is aware that it's part of XML::Simple.

As for your question, did you ever read the documentation of the module
you're using? I guess not, or not well enough. You probably copied the
example and thought that it was all.

Search for "folding" in the documentation of XML::Simple.
 
V

vamsee.2005

John said:
<response status="sucess">
<value type="hash">
<item key="asdfas" value="hello"/>
<item key="adfa" value="hi"/>
</value>
</response>

XMLin is producing following below data structure from the above xml.
[..]

What to do inorder to XMLin to force create the below datastructure.

Name the module you use instead of a method of this module. Not everybody
is aware that it's part of XML::Simple.

As for your question, did you ever read the documentation of the module
you're using? I guess not, or not well enough. You probably copied the
example and thought that it was all.

Search for "folding" in the documentation of XML::Simple.


Thanks for your reply, I didn't copied it, I am new to perl. I am
working on a php based web services kinda like RPC, Where as at client
side I am using perl script with AUTOLOADER, which will emulate missing
methods and post that info in the form of xml to php web service and
get the returned value in the form of xml and parse it and return it in
desired data structure to the calling sub routine.

I also have xml snippet
<response status="success">
<value type="array">
<item value="hello"/>
<item value="hi hi"/>
</value>
</response>

for this XMLin in XML::Simple giving the following data structure
$VAR1 = {
'value' => {
'item' => [
{
'value' => 'hello'
},
{
'value' => 'hi hi'
}
],
'type' => 'array'
},
'status' => 'sucess'
};
So I was curious about the differences, Now i know the problem, thanks
for replying.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top