This is a migrated thread and some comments may be shown as answers.

XML Format

1 Answer 80 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Vitor
Top achievements
Rank 1
Vitor asked on 21 May 2014, 11:58 AM
Hi, I´m trying to read an XML from a webservice to a datagrid, but I can´t fill the datagrid with the values. What I´m doing wrong?

The webservice returns:

<?xml version="1.0" encoding="UTF-8"?>
<ArrayOfTabela2 xmlns="http://tempuri.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <tabela2>
    <codigo>F</codigo>
    <descricao>Feminino</descricao>
  </tabela2>
  <tabela2>
    <codigo>M</codigo>
    <descricao>Masculino</descricao>
  </tabela2>
</ArrayOfTabela2>

And the HTML5 file is the following:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link href="styles/kendo.common.min.css" rel="stylesheet" />
    <link href="styles/kendo.default.min.css" rel="stylesheet" />
    <script src="js/jquery.min.js"></script>
    <script src="js/kendo.all.min.js"></script>
</head>
<body>

<div id="grid"></div>
<script>
var dataSource = new kendo.data.DataSource({
  transport: {
    read: {
 type: 'POST',
 processData: false,
      dataType: "xml",
      url: "http://localhost:28301/Vacinacao.asmx/retornaDataTable?tabela=SEXO",
 contentType: "text/xml"
    }
  },
  schema: {
    type: "xml",
    data: "/ArrayOfTabela2/tabela2",
    model: {
      fields: {
        codigo: "codigo/text()",
        descricao: "descricao/text()"
      }
    }
  }
});
dataSource.read();
$("#grid").kendoGrid({
  dataSource: dataSource,
  pageable: true
});
</script>

</body>
</html>

If I change the block bellow for a fixed data, it works fine.
  transport: {
    read: {
 type: 'POST',
 processData: false,
      dataType: "xml",
      url: "http://localhost:28301/Vacinacao.asmx/retornaDataTable?usuario=DES_VALE&senha=DES_VALE&tabela=SEXO",
 contentType: "text/xml"
    }
  },
-------
data: '<?xml version="1.0" encoding="UTF-8"?><ArrayOfTabela2 xmlns="http://tempuri.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><tabela2><codigo>F</codigo><descricao>Feminino</descricao></tabela2><tabela2><codigo>M</codigo><descricao>Masculino</descricao></tabela2></ArrayOfTabela2>',

Thanks for any help!

Vitor

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 23 May 2014, 07:24 AM
Hi Victor,

Looking at the provided code the configuration seems to be ok. However, you should verify that the webservice is returning the expected response and it is formatted appropriately. Also you should verify that there are no errors on the page as well as that the request executes successfully. 
 

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Data Source
Asked by
Vitor
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or