let text = '<msg><title>The Title</title><info priority="urgent"/></msg>'; let doc = $.createXMLDocument(text); // Does a <tag> exist? let title = $(doc).find('title'); if (title.length == 0) { // No <tag> } // Get the text in a <tag> let title_txt = $(doc).find('title').text(); // Get an attribute let priority = $(doc).find('info').attr('priority');.createXMLDocument is defined in: http://plugins.jquery.com/project/createXMLDocument
Programming Tips - jQuery: Parse XML
Date: 2010jul22
Language: javaScript
Q. jQuery: Parse XML
A. Use find() text() and attr() and .length like this: