Xml read

joed's picture
Hi there, I am having a slight problem with an xml local read. I am currently not receiving any output for an e4x query on the file. Any related info would be great. ************Code************ this.serviceName = "readfile2"; this.documentation = "TODO: Add service level documentation here" ; toString.documentation = "TODO: Add operation level documentation here" ; toString.inputTypes = { /* TODO: Add input types of this operation */ }; toString.outputType = "String"; /* TODO: Add output type here */ //toString.outputType = "#raw"; //toString.outputType = "any"; //toString.outputType = "xml"; function toString() { var file = new File("sample.xml"); file.openForReading(); var readfile = new XML(file.readAll()); file.close(); var keywordread = readfile.Library.Book.Title.toString(); return keywordread } ************Code************ ************XML************-sample.xml GeographySmith ************XML************ Thanks Joe
keith's picture

Have a look at the version sample

Hi Joe, You could have a look at the version sample. That's implemented in this same way. Thanks, Keith. Blog : http://www.keith-chapman.org
joed's picture

I tried the basis of some

I tried the basis of some functions of the version script file as the skeleton but have had no luck receiving a string response or error.
keith's picture

I presume that the problems

I presume that the problems you are having is with E4X. For starters just return the complete XML, if that works you can build on that. You could refer [1] for a E4X quick start guide. Thanks, Keith. Blog : http://www.keith-chapman.org [1] http://wso2.org/project/mashup/1.5.1/docs/e4xquickstart.html
jonathan.wso2.com's picture

Lost your sample XML

The sample XML didn't come through on your post - I suspect if you remove ".Library" from your query (assuming that's the name of the document element of the XML file) it will work. The new XML() command returns the document element, as opposed to the document node if you're used to DOM or XPath.
joed's picture

Worked great. Thanks joed

Worked great. Thanks joed
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)