Click here to Skip to main content
15,075,944 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

Our current service was developed in WCF and most of the method return as DataTable and string combination.

Now they need to develop a web base on this service but don't need to restructure or modify the code, just return it as json to support http request.

Below is my example data:

<DataTable xmlns="">
	<xs:schema id="NewDataSet" xmlns:xs="" xmlns="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
	<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="TableName" msdata:UseCurrentLocale="true"><xs:complexType>
	<xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element name="TableName"><xs:complexType><xs:sequence><xs:element name="TraID" type="xs:int" minOccurs="0"/><xs:element name="TraDate" type="xs:dateTime" minOccurs="0"/></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema>
	<diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
		<DocumentElement xmlns="">
			<TableName diffgr:id="TableName1" msdata:rowOrder="0">

			<TableName diffgr:id="TableName2" msdata:rowOrder="1">

AngularJS $http method:

        url: api_url + "/GetTra?PassKey=" + passkey,
        method: "GET",
        headers: {
            'Content-Type': 'application/json; charset=utf-8'
        dataType: 'json'
    }).then(function (r) {
    }, function (e) {


so my problem is how can I get above xml data as an array or object to display in a view?

I have tried something like this but it says got undefined of tag name
var transaction = [];
    var tra = {


    function myFunction(xml) {
        var i;
        var xmlDoc = xml.responseXML;
        var data = xmlDoc.getElementsByTagName("TableName");
        for (i = 0; i < data.length; i++) {
            var d = data[i];
            tra.TraID = d[i].getElementsByTagName("TraID")[0].childNodes[0].nodeValue;
            tra.TraDate = d[i].getElementsByTagName("TraDate")[0].childNodes[0].nodeValue;

Thank you for your help in advance.

What I have tried:

I try to use some standard xml function from google but it not working in this xml data format, so please help me out.
Updated 27-Jul-16 0:18am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900