Can XML be parsed reliably using jQuery's $(responseXML) syntax?

前端 未结 3 1932
有刺的猬
有刺的猬 2020-12-02 02:52

I\'m currently looking for an easy way to extract information from server XML responses using JavaScript. jQuery seems like a good candidate for this.

When it comes

3条回答
  •  醉梦人生
    2020-12-02 03:13

    the jQuery ajax documentation adds http://api.jquery.com/jQuery.ajax/:

    dataType

    "xml": Returns a XML document that can be processed via jQuery.

    ...If the server reports the return data as XML, the result can be traversed using normal XML methods or jQuery's selectors...

    Also at http://api.jquery.com/jQuery/

    When XML data is returned from an Ajax call, we can use the $() function to wrap it in a jQuery object that we can easily work with. Once this is done, we can retrieve individual elements of the XML structure using .find() and other DOM traversal methods.

提交回复
热议问题