Solved

Parse XML return from a Flex HTTP Service Post

Posted on 2007-11-16
6
9,743 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
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…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now