1

XML RESPONSE

(...)
<wfs:InsertResult>
<ogc:FeatureId fid="CRM_PROCES.1677" xmlns:ogc="http://www.opengis.net/ogc"/>
<ogc:FeatureId fid="CRM_PROCES.1690" xmlns:ogc="http://www.opengis.net/ogc"/>
</wfs:InsertResult>
(...)

I want to get fid number (In this case 1677, 1690) in jquery.

1 Answer 1

1

You can use $.parseXML( data ) to create an XML Document in javascript. Then you can use jQuery to fetch stuff, like:

var xmlDoc = $.parseXML("<XML> COMES HERE </XML>");
var $xml = $(xmlDoc); // We <3 documentations with examples :)
var els = $xml.find("[fid]");
els.each(
    function (i,e) {
        console.log($(e).attr("fid"));
    }
);

I also recommend this answer: https://stackoverflow.com/a/25089647/357403

Or you could do it with the builtin DOMParser, in XML mode:

var oParser = new DOMParser();
var xmltext = "<wfs:InsertResult> \
<ogc:FeatureId fid='CRM_PROCES.1677' xmlns:ogc='http://www.opengis.net/ogc'/> \
<ogc:FeatureId fid='CRM_PROCES.1690' xmlns:ogc='http://www.opengis.net/ogc'/> \
</wfs:InsertResult>";
var oDOM = oParser.parseFromString(xmltext, "text/xml");
var xDOM = $(oDOM);
xDOM.find("[fid]").each(
    function (i,e) {
        console.log($(e).attr("fid"));
    }
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.