Michael Hill wrote:
Your post has sat for a few hours, probably because it is unclear what
you are trying to do. I don't think a choice of XML or array is your
problem - they aren't really competing technologies. XML is for
transmitting data, arrays are for storing, manipulating and retrieving
data in memory.
I am creating a page where I want to dynamically fillin the contents of a
table based on user selections.
This points to using a select with options. The values you want in the
table can be either the value of the option or the displayed text (or
both) that the user selects. You can use different elements to
populate your table, it doesn't have to use just one type of UI
element.
You could also use radio buttons or checkboxes where appropriate.
The page is created from a cgi.
Is this relevant? I presume you want the client to be doing this
stuff, not the server?
I have a number of rows, say 150 that I want to hide in the page, either
with a xml or in an array as per below.
Rows? Or do you mean records? How are you associating data items with
user selections? It doesn't necessarily preclude using select and
option elements as above, but it might.
I don't which one I'd like to use
[...]
So either XML or CSV? How do the data get into the array? Do you
want to read a file from the server or load the data in the page?
Using selects and options will still do the trick.
I have the requirement to dynamically use javascript to populate some
portions of my page from either the array or xml structure.
I also have the requirement to present some of my data in sorted form.
You can use XSLT to sort XML, but as far as I know, there are no
cross-browser solutions (but I haven't looked at it seriously in a
little while).
But an array would be very much faster, since it would be already in
memory.
My questions then are:
1) Which method would be faster to post to the page, a) data from the array,
or 2) data from the xml.
Post? Do you mean load into the page? Almost certainly CSV, though it
is not in vogue. XML would be 3 to 5 times more bulky and costs a lot
more to parse.
2) Seeing that I have a requirement to sort, is there anyway I can sort the
contents of the xml in place, then pull from it.
"in place"? Is that on the server? On the client? Pull it from where?
3) I typically have some problems with data loaded to arrays, because users
like to add double and single quotes to data structures and once put into an
array produce errors and prevent the page froml loading so if the data is
loaded in an xml structure I shouldn't have this problem should I?
So users can not only select data, they can key it in too? When you
read the value of a text or textarea, it is a string. You do not need
to worry about what is in the string unless you are going to parse it
or do something with it (like send it back to the server) but using
escape() fixes that.
Any comments appreciated.
Sorry I couldn't be more helpful. Perhaps if you posted a small
example of what you are trying to do...
--
Fred.