should I use xml or array?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Hill

    should I use xml or array?

    I am creating a page where I want to dynamically fillin the contents of a
    table based on user selections.

    The page is created from a cgi.

    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.

    I don't which one I'd like to use

    The xml would look like:
    <xml id="test1">
    <root>
    <data>
    <col1></col1> <col2></col2>
    </data>
    <data>
    <col1></col1> <col2></col2>
    </data>
  • Fred Oz

    #2
    Re: should I use xml or array?

    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.
    [color=blue]
    > I am creating a page where I want to dynamically fillin the contents of a
    > table based on user selections.[/color]

    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.
    [color=blue]
    >
    > The page is created from a cgi.[/color]

    Is this relevant? I presume you want the client to be doing this
    stuff, not the server?
    [color=blue]
    >
    > 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.[/color]

    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.
    [color=blue]
    >
    > I don't which one I'd like to use[/color]
    [...]

    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.
    [color=blue]
    > 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.[/color]

    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.
    [color=blue]
    >
    > 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.[/color]

    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.
    [color=blue]
    >
    > 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.[/color]

    "in place"? Is that on the server? On the client? Pull it from where?
    [color=blue]
    >
    > 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?[/color]

    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.
    [color=blue]
    >
    > Any comments appreciated.[/color]

    Sorry I couldn't be more helpful. Perhaps if you posted a small
    example of what you are trying to do...

    --

    Fred.

    Comment

    Working...