Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

jParse simple example

151 views
Skip to first unread message

Komal

unread,
Apr 26, 2012, 2:23:47 AM4/26/12
to
Hi,

I am using jParse for the first time (I'm an absolute beginner in
javascript too). My task is to load and parse a simple xml using
javascript. I tried the regular code of

xhttp = new ActiveXObject("Microsoft.XMLDOM");

to load/parse xml. But that somehow doesn't work. No error too.

After googling around, I found jParse to be a common way to do the
task. I tried the following example straight from the website, but for
same "no result, no error". I tried this in both FF (v.11) and Chrome
(v5.x). can anyone please guide me. Can there be any specific browser
setting which might be preventing my code to run?

My code:

<html>
<head>
<title>Read XML in Microsoft Browsers</title>
<script src="jparse.js" type="text/javascript">
<script type="text/javascript">

function start(){
jQuery('#jparse-meta').html('<p>starting...</p>');
}

function finish(){
jQuery('#jparse-meta').remove();
if ($('#ajax-cont').html() == 0) {
$('#ajax-cont').append('<h4>No entries</h4><p>Pls. check back
later</p>');
}
}

$(function(){
$('#ajax-cont').jParse({
ajaxOpts: {url: 'a.xml'},
elementTag: ['company', 'employee', 'turnover'],
output: ' <div class="feed-entry"><h4><a href="jpet01">jpet00</a></
h4><p><a href="jpet4">jpet03 Comment(s)</a><p>jpet02</p></p></div>',
precallback: start,
callback: finish
});
});


</script>
</head>

<body>
<div id="jparse-meta" style="text-align: center; margin: 15px 0 0
0;">
<p><a href="http://feeds.feedburner.com/KyleRushBlogPortfolio">Click
here</a> to see the kylerush.net blog RSS feed.</p>
</div><!--/#jparse-meta-->
<div id="ajax-cont"></div><!--/#demo-cont-->
</body>
</html>


a.xml is:

< ?xml version="1.0" encoding="UTF-8" ?>
<company>
<employee id="001" >John</employee>
<turnover>
<year id="2000">100,000</year>
<year id="2001">140,000</year>
<year id="2002">200,000</year>
</turnover>
</company>


Thanks in advance!

hansraa...@gmail.com

unread,
Nov 20, 2013, 10:11:33 AM11/20/13
to
You are not calling the jQuery library.
Use <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
0 new messages