I have an HTTPservice
id="myhttp"
url="site.com/script.php"
method="POST"
resultFormat="xml"
The script it uses returns
$output = '<worked>' . $worked . '</worked>';
echo $output;
Problem is when I try to read worked, it tells me the variable worked is not there
event.result.worked
myhttp.lastResult.worked
The only thing that works is using toString()
myhttp.lastResult.toString()
or event.result.toString()
What am I doing wrong?
I plan to add other variables to the output time, so need to access each time and worked separately.
I may also need to return multiple responses each with their own worked and time values. How do I do that. I was thinking to not use XML. Is there a more lightweight option. Flex shows I have the following options: array e4x flashvars object text xml
You should use e4x as your return type. By declaring your return type as xml, you tell flex to handle it as an XMLNode, which is legacy and shouldn't be used.
If you need to use XMLNode for some unknown reason, you can get the value of the text by using event.result.nodeValue.
Should your return type be e4x?
Related
Since we will just be storing short simple strings here, why is it presented as the default option when we could be using a simpler simple_array? Is it just a matter of preferences?
My wild guess would be:
simple_array uses simple explode/implode to deserialize/serialize data, which does not offer any sort of escaping of a comma.
Example:
$arr = ["some,foo","and","another","bar"]; // Notice that the first string contains ",".
echo implode(',', $arr);
This produces some,foo,and,another,bar, but notice exploding would produce array of 5 elements (not 4):
["some","foo","and","another","bar"]
This would clearly produce invalid behavior in the app.
There was a feature request opened a couple of years ago about this, but it was closed exactly in favor of using the JSON type:
https://github.com/doctrine/dbal/issues/3300
I am trying to put multiple values inside this content with this XQuery Expression Builder. I tried to use a string function like thisfn:concat($body, $inbound, $inbound), but this does not seems to keep the whole message.
Is there any way that I can put all these variables in one report action? If this is possble then how should I read these values out after they are stored in the database(some key value structure would be perfect).
You only need to form a xml with the content you want to show in your report:
<report>
<body>{$body}</body>
<inbound>{$inbound}</inbound>
...
</report>
the only requirement is that the output have to be an XML no matter the structure.
Not sure, but I would try something like this:
<myroot>{$body, $inbound, $outbound}</myroot>
Or if you really need a string returned:
fn:serialize(<myroot>{$body, $inbound, $outbound}</myroot>)
Note, fn:serialize is only in OSB 12c+.
i am trying to read from xml string But ,
` XmlReader reader=XmlReader.Create(new StringReader(stringXml)`
reader is always none. why is reader objest none ?
You have to call the read function.
reader.Read();
Here is the answer for your question. There seems to be no problem and the XmlReader is ready to be utilized.
Actually, if you are open to use .NetFramework 3.5 and higher you could benefit from using Linq To Xml:
XElement x = XElement.Load(new StringReader(s));
this happened to me in code that had been working for years. there were two paths for populating the xml string used in creating the xReader. The first pulled xml from a text parameter. If the text parameter was empty then it would fetch the string from sql server. If the text parameter was null, however, then I was getting "none" from the xReader. This despite the fact that SQL return perfectly formed xml. If the text parameter was an empty zero-length string, however, then everything worked fine, that is, the fetch to SQL ran, fetch xml and loaded the reader. It was like the runtime .net engine was running both paths simultaneously and giving me the worst possible outcome, instead of the desired outcome.
I'm breaking my head over this for a while now and I have no clue what I do wrong.
The scenario is as followed, I'm using swfupload to upload files with a progressbar
via a webservice. the webservice needs to return the name of the generated thumbnail.
This all goes well and though i prefer to get the returned data in json (might change it later in the swfupload js files) the default xml data is fine too.
So when an upload completes the webservice returns the following xml as expected (note I removed the namespace in webservice):
<?xml version="1.0" encoding="utf-8"?>
<string>myfile.jpg</string>
Now I want to parse this result with jquery and thought the following would do it:
var xml = response;
alert($(xml).find("string").text());
But I cannot get the string value. I've tried lots of combinations (.html(), .innerhtml(), response.find("string").text() but nothing seems to work. This is my first time trying to parse xml via jquery so maybe I'm doing something fundemantally wrong. The 'response' is populated with the xml.
I hope someone can help me with this.
Thanks for your time.
Kind regards,
Mark
I think $(xml) is looking for a dom object with a selector that matches the string value of XML, so I guess it's coming back null or empty?
The First Plugin mentioned below xmldom looks pretty good, but if your returned XML really is as simply as your example above, a bit of string parsing might be quicker, something like:
var start = xml.indexOf('<string>') + 8;
var end = xml.indexOf('</string>');
var resultstring = xml.substring(start, end);
From this answer to this question: How to query an XML string via DOM in jQuery
Quote:
There are a 2 ways to approach this.
Convert the XML string to DOM, parse it using this plugin or follow this tutorial
Convert the XML to JSON using this plugin.
jQuery cannot parse XML. If you pass a string full of XML content into the $ function it will typically try to parse it as HTML instead using standard innerHTML. If you really need to parse a string full of XML you will need browser-specific and not-globally-supported methods like new DOMParser and the XMLDOM ActiveXObject, or a plugin that wraps them.
But you almost never need to do this, since an XMLHttpRequest should return a fully-parsed XML DOM in the responseXML property. If your web service is correctly setting a Content-Type response header to tell the browser that what's coming back is XML, then the data argument to your callback function should be an XML Document object and not a string. In that case you should be able to use your example with find() and text() without problems.
If the server-side does not return an XML Content-Type header and you're unable to fix that, you can pass the option type: 'xml' in the ajax settings as an override.
What’s the difference between Response.Write() and Response.Output.Write()?
There is effectively no difference, although Response.Output.Write() provides more overloads which can allow you to pass different parameters. Scott Hansleman covers it in depth.
They both write to the output stream using a TextWriter (not directly to a Stream), however using HttpContext.Response.Output.Write offers more overloads (17 in Framework 2.0, including formatting options) than HttpContext.Response.Write (only 4 with no formatting options).
The HttpResponse type does not allow direct 'set' access to its output stream.
Nothing really.
But. Response.Write takes the stream in the Response.Output property. You could set another Output stream, and in that way instead of writing back to the client, maybe write to a file or something crazy. So thats there relation.
Response.Output.Write(): It is used to display any type of data like int, date, string etc. i.e. It displays the formatted output.
Response.Write(): To display only string type of data i.e. It's can't display formatted output().
To display formatted output from Response.Write() you can write:
Response.Write(String.Format(" ",___));