How to embed an XML file in HTML?

I am creating a simple comic book web application using HTML and JavaScript. Since people who are not very technical should be able to add new comics, I thought about using an XML file as a configuration file.

I thought about using JSON and decided against it, mainly because a comma is used (no comma between the two elements breaks it, but the comma at the end of the list also breaks it.).

However, now my question is: how can I embed this XML file? Should I use a tag <link rel= />or something else as a tag <embed src= />? And how can I read information from XML nodes in JavaScript?

+5
source share
2 answers

JavaScript, . jQuery - . jQuery , XML-.

http://api.jquery.com/jQuery.parseXML/ XML- .

http://think2loud.com/224-reading-xml-with-jquery/ XML . - AJAX: , foo.xml html- ( jQuery):

$( function() {
    $.ajax({
        type: "GET",
    url: "foo.xml",
    dataType: "xml",
    success: myHandler(xml) {
    }
    });
});
+8

xml. :

<html>
  <xml Id = msg>
      <message>
        <to> Visitors </to>
        <from> Author </from>
        <Subject> XML Code Islands </Subject>            
      </message>
  </xml>
</html> 
-1

All Articles