aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Ajax question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajax question" Watch "Ajax question" New topic
Author

Ajax question

Jian Yi
Ranch Hand

Joined: Feb 01, 2002
Posts: 127
Hi,

I'm new to Ajax. Does Ajax have a limit on how big the xml document returned by the jsp should be? I have this weird problem... My Jsp returns an xml document like this:

<?xml version="1.0" ?>
<Entry>
<Dealer>407209</Dealer>
<Device>33333</Device>
</Entry>
<Entry>
<Dealer>405A11</Dealer>
<Device>33334</Device>
</Entry>

And FireBug gave me an error:

junk after document element

<Entry> ^

This <Entry> refers to the second <Entry> element. Why is this happening? How can I fix it?

Thanks,
Yi

P.S. my jsp looks like this:

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

That's not valid XML. A valid XML document needs a root element. You don't have one. So you need to add something like:



GenRocket - Experts at Building Test Data
Jian Yi
Ranch Hand

Joined: Feb 01, 2002
Posts: 127
I think I know why my program is wrong. The returned xml document can only have one root element. I should return something like this:

<?xml version="1.0" ?>
<Root>
<Entry>
<Dealer>407209</Dealer>
<Device>33333</Device>
</Entry>
<Entry>
<Dealer>405A11</Dealer>
<Device>33334</Device>
</Entry>
</Root>

Am I correct? If so, I need some assistance to parse this document. Does anyone have some sample code snippets?

Thanks!
Yi
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Basic idea:

var xmlDoc = req.responseXML.contentDocument;
var myEntry = xmlDoc.getElementsByTagName("Entry");

Loop

var item0 = myEntry[i].childNodes.item(0);
var item1 = myEntry[i].childNodes.item(1);

Eric
Jian Yi
Ranch Hand

Joined: Feb 01, 2002
Posts: 127
Thank you both. There are so many nice experts out here!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Who said I was nice....man I was working on my bad boy image!

Eric
Jian Yi
Ranch Hand

Joined: Feb 01, 2002
Posts: 127
Okay, bad boy, giddy-up!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ajax question