Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Parse XML return from a Flex HTTP Service Post

Posted on 2007-11-16
6
Medium Priority
?
9,812 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 720 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 1280 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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. 
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month12 days, 8 hours left to enroll

971 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