Solved

Parse XML return from a Flex HTTP Service Post

Posted on 2007-11-16
6
9,783 Views
Last Modified: 2010-04-21
(NOVICE ALERT) I am using a Flex HTTPService post to send data to an API that returns XML

I can not seem to parse the return correctly.

The returned XML is :
<connector_ret>
  <function name="contact_create">
    <ret_val name="c_id" type="integer">30</ret_val>
  </function>
</connector_ret>

my HTTPService ID = "theRequest"

So I would think     theRequest.lastResult.connector_ret.function.ret_val would = 30  

I am clearly missing something, which does not surprise me.  Any help would be fantastic!!
0
Comment
Question by:jeresimpson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 10

Assisted Solution

by:Savong
Savong earned 180 total points
ID: 20302198
Typically you don't actually reference the root node, for whatever reason the object referenced is the root.  So if I'm reading that correctly (I haven't built a test for this) it should work if you remove connector_ret from your call.
0
 

Author Comment

by:jeresimpson
ID: 20302449
Savong:  Thanks for the help

In flex Builder 2 when I try theRequest.lastResult.function.ret_val
function produces an error and the word turns aqua in in Flex Builder

The error reads:  1084: Syntax error: expecting identifier before function.
Do you know a way around this?
0
 
LVL 10

Expert Comment

by:Savong
ID: 20302930
Well, function is a reserved word is there any way to change the XML?  Changing function to another word might resolve the issue.  Or you might be able to try:
theRequest.lastResult["function"].ret_val

Not sure about that one, but it's worth a shot.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jeresimpson
ID: 20305279
Savong,

Thanks
Unfortunately I can not change the XML return.
theRequest.lastResult["function"].ret_val does not work.

Was worth a shot though, like you said.
0
 
LVL 23

Accepted Solution

by:
Siva Prasanna Kumar earned 320 total points
ID: 20308029
here is a quick fix.

This is pointing to the first element of type ret_val in the complete XML result;

theRequest.lastResult..ret_val[0] = 30;

Open in new window

0
 

Author Closing Comment

by:jeresimpson
ID: 31409677
Thanks for the help!  This worked great.  I structured my result format to e4x and used the solution provided.  
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question