Page 1 of 1

Data mapping xml attributes

Posted: Fri Jun 07, 2013 12:25 pm
by Kjell

My rest service returns an xml which looks like:
ulli
span class="type1"data1/span
span class="type2"data2/span
span class="type3"data3/span
/li/ul

And I want to map $(".type2").val() to an input text box.

It works fine if I change the javascript span[0] to span[1]
'responseMapping': [{
'PATH': ['html', 'body', 'div', 'ul', 'li', 'span[1]', 'content'],

But can it be done by using the data mapping only, i.e. without any javascript editing?


Data mapping xml attributes

Posted: Fri Jun 07, 2013 12:59 pm
by Kjell

The xml was not readable, I try with this
<!--
<ul<li
<span class="type1"data1</span
<span class="type2"data2</span
<span class="type3"data3</span
</li</ul
--


Data mapping xml attributes

Posted: Fri Jun 07, 2013 1:00 pm
by Maryna Brodina

Hello! Please use < code < /code tag to post your code.


Data mapping xml attributes

Posted: Fri Jun 07, 2013 6:41 pm
by Kjell

Ok,

My rest service returns an xml which looks like:
code
<ul><li>
<span class="type1">data1<&#47;span>
<span class="type2">data2<&#47;span>
<span class="type3">data3<&#47;span>
<&#47;li><&#47;ul>
/code

And I want to map $(".type2").val() to an input text box.

It works fine if I change the generated javascript span[0] to span[1]
'responseMapping': [{
'PATH': ['html', 'body', 'div', 'ul', 'li', 'span[1]', 'content'],

But can it be done by using the data mapping only, i.e. without any javascript editing?

Or is there a better way to get the data than to edit the generated javascript?


Data mapping xml attributes

Posted: Fri Jun 07, 2013 7:42 pm
by Kateryna Grynko

Hi,

We'll take a look.


Data mapping xml attributes

Posted: Mon Jun 10, 2013 6:11 am
by Kateryna Grynko

Sorry, no updates yet. Working on it.


Data mapping xml attributes

Posted: Mon Jun 10, 2013 10:40 am
by Kjell

I hope you can find a solution for this. I can also imagine that there are people that want to write simple mobile apps towards existing web sites which are returning html.


Data mapping xml attributes

Posted: Mon Jun 10, 2013 12:13 pm
by Kateryna Grynko
  1. You should not interfere in the generated service code until it's finally exported from the builder.

    1. There is no way to do this. It is usually assumed that the filtering of data is on the server side but the server does not send extra data.

      You can create a generic service and handle the response as you need, and then map it to the screen.

      You can also pass the usual response to localStorage and add there JS code that performs manual mapping.