1
votes

Breeze render xml column (SQL xml data column) as it is (not converted to object as Breeze used to). For example, bellow is data received client-side from Breeze :

<employee><firstname>Martin</firstname><lastname>MALONGA</lastname><age>74</age></employee>
  1. How to access this xml element at client-side using Breeze? are they functions like xquery inside breeze platform?
  2. How to update xml element client side and hope Breeze will transfer it to server?

For the 1st question I'd tried parser.parseFromString and get something but with a painful gymnastic labor; hope someone will pull out a better approch.

1
Are you asking how do you use breeze with an XML-based API? I don't believe Breeze supports XML responses, but I'd imagine you could hack together something by intercepting the HTTP response and converting it to JSON. Can you try to make your question a bit clearer? - Chief

1 Answers

1
votes

You can query the XML using jquery selectors.

Access element

var employee = $(returnedBreezeObservable());
var firstname = employee.children('firstname').text();

Change element

NOTE: the xmlToString function was taken from this question.

function xmlToString(xmlData) { 
    var xmlString;
    //IE
    if (window.ActiveXObject){
        xmlString = xmlData.xml;
    }
    // code for Mozilla, Firefox, Opera, etc.
    else{
        xmlString = (new XMLSerializer()).serializeToString(xmlData);
    }
    return xmlString;
}   

var employee = $(returnedBreezeObservable());
employee.children('firstname').text('John');
employee.children('lastname').text('Doe');
returnedBreezeObservable(xmlToString(employee));