cancel
Showing results for 
Search instead for 
Did you mean: 

Outbound data connectivity-parsing XML in server side javascript

Former Member
0 Kudos

Hi all,

I am trying to get data from a CGI service which provides the data only in XML format. I have used the xshttpdest file and xsjs file to access the service. I am able to get the data as text into a variable and display is as text.

The service returns:

<body>

<script/>

<response>

<status>
0

</status>

<hour value="1">

<inCount>
30

</inCount>

<outCount>

18

</outCount>
</hour>
</response>

</body>

But what I want to achieve is to parse the XML file and put the data accordingly into respective tables. I am aware of such a functionality in terms of JSON format. See blog http://scn.sap.com/community/developer-center/hana/blog/2013/07/01/sap-hana-sps6--various-new-develo...

The Outbound data connectivity section explains about such feature.

But I am getting the output in XML format and need to feed this into tables. Is there a way achieve this?

Kindly suggest any thing that can be done to get the data in tables.

Thanks & Regards,

Shreepad Patil

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Thanks to SAP - they have done xmltojson parser:

and just smth like this...

$.import('sap.hana.xs.lm.core', 'xml2json');

var xml2json = $.sap.hana.xs.lm.core.xml2json.xml2json;

var res = xml2json.parse(t);

0 Kudos

Hello Dmitriy

I had similar requirements. It was really helpful from your suggestion. Do you know, where will i get official information regarding the apis provided in this library. I saw the library but it would be more helpful if I get API documentation for this. Thank you.

Best Regards
Vivek

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

This isn't a public API.  Just internal functionality of the HALM tool. I wouldn't recommend reusing it as SAP wouldn't support it as a general API library. 

0 Kudos

Hello Thomas

Thank you for your recommendation.

Currently we are parsing our XML-schema with complex string matching. Our schema is huge and it takes a lot of time. This way of XML to json conversion and then extracting data looked simpler way of doing it. Although, i am not sure if this will take the same time as parsing xml to json for the first time.

Is there any official support planned for XML-parsing in XS server side?

Best Regards

Vivek

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>Is there any official support planned for XML-parsing in XS server side?

Yes this is planned and close to finished. It might make it for SPS09.

SergioG_TX
Active Contributor
0 Kudos

this is now available on SP09

shyam_uthaman
Participant
0 Kudos

Hi Thomas,

Can you please have a look at the below issue?

Corresponding statement to JSON.stringify for XML outputs in XSJS

Thanks!

Answers (2)

Answers (2)

sreehari_vpillai
Active Contributor
0 Kudos

I Read your blog. Idea is cool. But think of a huge XML document which is to be parsed with string search . But I am sure there is no donut for you in xsjs to parse the XML body freely(like DOM parser).May be you can try reguar expression matching or such complex stuffs to parse it and make a JSON out of it.

Sreehari

Former Member
0 Kudos

Kindly refer the blog