Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Parse this (some.xml):
- <root><xline a="1" b="2" /><xline a="3" b="4" /></root>
- With this:
- <div id="parsed">Loading...</div>
- <script type="text/javascript" charset="utf-8">
- $(document).ready(function () {
- $.ajax({
- type:'GET',
- url:'some.xml',
- dataType: 'xml',
- success: function (x) {
- $("#parsed").html('');
- $(x).find('xline').each(function (i,itm) {
- var h = $("#parsed").html();
- var a = $(this).attr('a');
- var b = $(this).attr('b');
- h += '<p>a: '+a+', b: '+b+'</p>';
- $("#parsed").html(h);
- });
- },
- error:function() {
- alert('Server error.');
- }
- });
- });
- </script>
Add Comment
Please, Sign In to add comment