carri Posted September 22, 2010 Report Share Posted September 22, 2010 Hi, Im new with LabVIEW, and i have a problem using the web services. I want to have more information with the response of the web service, so I use XML to format the output (with "flatten to XML"). The problem is that i want to recieve the response in XML, and when i recieve the response, the symbols < and > of my XML tags had been modified. For example, i want to recieve some code like this: <Response> <Terminal> <Name> example </Name> <Value> <String> <Val> Example text </Val> </String> </Value> </Terminal> </Response> but i receive this: <Response> <Terminal> <Name> example </Name> <Value> <String> <Val> Example text </Val> </String> </Value> </Terminal> </Response> PS: Sorry for my english it is very poor. Quote Link to comment
Phillip Brooks Posted September 22, 2010 Report Share Posted September 22, 2010 You can use the Unescape XML function: http://zone.ni.com/reference/en-XX/help/371361D-01/glang/unescape_xml_string/ Quote Link to comment
carri Posted September 22, 2010 Author Report Share Posted September 22, 2010 thanks for the quick reply, but the change of the characters is in the response from the web service, not inside the VI, I don't know if i am explaining it well... Quote Link to comment
Ton Plomp Posted September 22, 2010 Report Share Posted September 22, 2010 The Webservice escapes it's response so it's easy to parse (and you cannot interfere between data and communication layer. You can use RegExes to find the Value and unescapes it to use it with XML functions: Ton Quote Link to comment
carri Posted September 22, 2010 Author Report Share Posted September 22, 2010 The idea is to use the web service with ajax, so i can parse the xml to load the result of the operation, so i can't use this solution. Can I configure the LabVIEW's response not to change that escapes characteres? or any similar solution? thanks for all responses. Quote Link to comment
John Lokanis Posted September 22, 2010 Report Share Posted September 22, 2010 You should not be seeing the & replacements when calling the web service. Try calling it from IE or Firefox and see if you still get them. I don't with any of my web services. This could be a problem with the tool you are using to call the web service and not LabVIEW. Any decent XML parser should know to convert < to a < character. Quote Link to comment
carri Posted September 22, 2010 Author Report Share Posted September 22, 2010 I'm using Firefox. I configure the output of the web service like a XML file, and I receive it well in my browser, but when I add some XML additional tags, the special characters of those tags were changed, so when i try to parse the XML response with javascript, it didn't recognize the < character like the < character. Quote Link to comment
ShaunR Posted September 23, 2010 Report Share Posted September 23, 2010 I'm using Firefox. I configure the output of the web service like a XML file, and I receive it well in my browser, but when I add some XML additional tags, the special characters of those tags were changed, so when i try to parse the XML response with javascript, it didn't recognize the < character like the < character. Use the javascript "html_entity_decode" function. html_entity_decode(string) Normal chars will remain unaffected but  &alt etc will be converted. Damn. Now I'm a text heretic Quote Link to comment
Aitor Solar Posted September 23, 2010 Report Share Posted September 23, 2010 You can also prepare your own XML and send it through the "Write Response.vi". Just configure the method VI output type to Stream instead of Terminal. I think this is the best solution as you can format the XML just the way you need, and avoid all that "name - value" tags. Saludos, Aitor Quote Link to comment
carri Posted September 23, 2010 Author Report Share Posted September 23, 2010 thanks for all responses!! I am thinking to try that two last solutions, that are just what i was looking for. Thanks!! PS: Again, sorry for my poor english. Quote Link to comment
carri Posted September 26, 2010 Author Report Share Posted September 26, 2010 In the end I used another different solution, it was with ESP, so the solution is as Aitor said, but cleaner, as the VI passes the variables to the ESP code, and this code formats the output to send to client Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.