PDA

View Full Version : Best Way To Display And Sort This XML Document


Antoniohawk
06-25-2004, 12:22 AM
I have developed a javascript tree menu, and want to import the data from an xml document. The [menu (http://null.ithium.net/andrew/New%20Gen%20Menu%20Tree/wishlist2.html)] and the [xml document (http://null.ithium.net/andrew/New Gen Menu Tree/wishlist2.xml)]. I was thinking that loading the xml document with javascript would be my best bet, so that I would then have the capability of the sorting the items. Any comments on the tree menu, xml document, or method of importation are welcome.

neofibril
06-28-2004, 10:54 PM
The [menu (http://null.ithium.net/andrew/New_Gen_Menu_Tree/wishlist2.html)]
You might want to remove the under_scores from that link...

gsnedders
06-28-2004, 11:57 PM
I wouldn't hold the main values as attributes...

neofibril
06-29-2004, 12:01 AM
e.g., Is the unordered list to be generated in tandem with the enumeration of data?

Antoniohawk
06-29-2004, 05:43 AM
The ultimate goal of using xml for this project is that it would be easier for less computer literate people to create a list of their own. I would like to be able to load the items from an xml file and later create sort functions that would allow people to sort by author, manufacturer, or price (when it gets added). I hope that that helps, if not, please ask for any information that you need to better help me. :)

neofibril
06-29-2004, 02:50 PM
Ok, what is your first task?

Antoniohawk
06-29-2004, 08:47 PM
I'm not really understanding why you are asking that. Maybe I'm not following you, but I thought that I had covered that in my explanation. :confused:

neofibril
06-29-2004, 10:57 PM
Of the series of sub-concepts that are your project, what is the first part of one that you'd like to discuss?

Antoniohawk
06-29-2004, 11:37 PM
Alright, I understand what you were asking for before, sorry about the confusion. The first order of business would be to load the xml document into a html page.

neofibril
07-01-2004, 02:23 PM
Are you looking for a script that returns the DOMDocument for both IE and Moz?

Antoniohawk
07-01-2004, 06:25 PM
Yes, I would prefer it to be crossbrowser. Maybe something similar to this one: [http://www.quirksmode.org/dom/importxml.html].

neofibril
07-01-2004, 07:51 PM
Just for getting an xml reference, or for generating an unordered list from the xml?

Antoniohawk
07-01-2004, 08:34 PM
I need the code for loading the xml document with javascript, but I will attempt to code the part for creating the unordered list.

neofibril
07-02-2004, 01:30 AM
This article provides an elaborate scheme for loading xml: A Cross-Browser DOM Document Wrapper (http://www.webreference.com/programming/javascript/domwrapper/);
there are some other notes here: XML Extras (http://www.mozilla.org/xmlextras/)

Apart from that, I've messed around with the XMLHttpRequest object:
Mozilla returns a DOMDocument object from responseXML.

IE returns an empty DOMDocument, unless responseXML.loadXML(responseText) is called.
This has something to do with the mime type not being text/xml (it might work from a server, though).
Instead of re-parsing that way, or using activeX, I just put an xml element into a fragment.


<script type="text/javascript">
var xDom;
function loadX()
{
var xGet;
try
{
xGet = new XMLHttpRequest();
xGet.open("get","wishlist2.xml", false);
xGet.send(null);
xDom = xGet.responseXML;
}
catch(e)
{
try
{
xDom = document.createDocumentFragment();
xGet = document.createElement("XML");
xGet.setAttribute("src", "wishlist2.xml");
xDom.appendChild(xGet);
xDom = xDom.getElementsByTagName("XML")[0];
}
catch(e)
{
return alert(e.message);
}
}
alert(xDom.documentElement.tagName);
}
</script>

Antoniohawk
07-02-2004, 01:56 AM
Sorry if I'm a bit slow with the learning curve, but I don't really understand your example. Is that the same sort of thing as I linked to in my prior post? Thanks a lot for helping me out and being patient. :)

neofibril
07-02-2004, 02:30 AM
The various methods, or combinations thereof, all return the same object.

Testing them out should give you an idea of whether there are performance differences.

If they all work just as well, I'd think the simplest solution would be best.