Solved

Parse XML return from a Flex HTTP Service Post

Posted on 2007-11-16
6
9,757 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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