通过缓存的HTML将XML配置文件传递给JavaScript

I need to pass data from an XML configuration file to JavaScript. The application needs to work entirely offline (I'll be using application cache and localstorage) and I was planning to generate the page using PHP. Is there an easy way to place the XML in the outputted document in such a way that it will not interfere with standard HTML parsing but still be easily accessible using JavaScript.

If, as suggested by the comments, you can use json instead, then you can set it to an html tags data attribute:

<?php $settings = array('name'=>'john');?>
<div id="mydiv" data-settings="<?php echo json_encode($settings); ?>"> <!-- --> </div>

Then retrieve it in javascript:

var mydiv=document.getElementById('mydiv');
var settings=JSON.parse(mydiv.dataset.settings);
alert(settings.name); //alerts john

or simply echo it into a script tag:

<script type="javascript">
    var settings=<?php echo json_encode($settings); ?>;
</script>