Solved

Parse XML return from a Flex HTTP Service Post

Posted on 2007-11-16
6
9,766 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Custom Ribbon doesn't refresh 7 98
API Soap Calls 4 126
any soltion create a connection to import XML file from website 4 51
Shredding xml into an oracle 11g Database 2 58
First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

765 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