Building a tree from a HTML report with DOM?

Discussion in 'Javascript' started by Craig, Dec 14, 2004.

  1. Craig

    Craig Guest

    I have a 3rd party product that output reports to html.

    It's quite old now and doesn't output some reports correctly.

    We have a report that should show a structure like this:

    Europe
    France
    Paris
    UK
    London
    Germany
    Munich
    Spain
    Madrid
    Americas
    USA
    New York
    Canada
    Toronto
    APAC
    Australia
    Canberra
    NZ
    Auckland

    The trouble is that it doesn't!

    The html output is like so (I've snipped it to save on space).

    <table>
    <tr>
    <td>Europe</td>
    </tr>
    <tr>
    <td> France</td>
    </tr>
    <tr>
    <td> Paris</td>
    </tr>
    <tr>
    <td> UK</td>
    </tr>
    <tr>
    <td> London</td>
    </tr>
    etc etc etc

    I take it because the "spaces" aren't &nbsp; it doesn't show
    correctly.

    Ideally I'd like to do something clever and make it a expandable tree
    so users can expand the company structure as they wish.

    Is this a possibility with DOM?

    Thanks in advance!
     
    Craig, Dec 14, 2004
    #1
    1. Advertising

  2. On 14 Dec 2004 07:14:10 -0800, Craig <> wrote:

    [snip]

    > I take it because the "spaces" aren't &nbsp; it doesn't show correctly.


    Yes, but the output should be changed entirely. The data is obviously a
    set of nested lists.

    [snip]

    > Is this a possibility with DOM?


    I don't believe so. The spaces will be collapsed and as this is the only
    form of structure to the data (unless you're abridging the mark-up), there
    will be no way to determine which "level" the table data actually belongs
    to. You'll have to preprocess the output directly or change to a competent
    program.

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
     
    Michael Winter, Dec 14, 2004
    #2
    1. Advertising

  3. Craig

    Evertjan. Guest

    Craig wrote on 14 dec 2004 in comp.lang.javascript:
    > Europe
    > France
    > Paris
    > UK
    > London
    >


    Use css classes:

    <style>
    ..continent {padding-left:0;}
    ..country {padding-left:20px;}
    ..capital {padding-left:40px;}
    </style>

    <table>
    <tr><td class=continent>Europe</td></tr>
    <tr><td class=country>France</td></tr>
    <tr><td class=capital>Paris</td></tr>
    <tr><td class=country>Britain</td></tr>
    <tr><td class=capital>London</td></tr>
    ....

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Dec 14, 2004
    #3
  4. Craig

    Guest

    Evertjan. wrote:
    > Craig wrote on 14 dec 2004 in comp.lang.javascript:
    > > Europe
    > > France
    > > Paris
    > > UK
    > > London
    > >

    >
    > Use css classes:
    >
    > <style>
    > .continent {padding-left:0;}
    > .country {padding-left:20px;}
    > .capital {padding-left:40px;}
    > </style>
    >
    > <table>
    > <tr><td class=continent>Europe</td></tr>
    > <tr><td class=country>France</td></tr>
    > <tr><td class=capital>Paris</td></tr>
    > <tr><td class=country>Britain</td></tr>
    > <tr><td class=capital>London</td></tr>
    > ...
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
     
    , Dec 15, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    575
  2. Joris Gillis
    Replies:
    2
    Views:
    1,559
    Joris Gillis
    Jun 16, 2006
  3. Stub

    B tree, B+ tree and B* tree

    Stub, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    10,202
  4. Lukasz Indyk
    Replies:
    4
    Views:
    143
    Lukasz Indyk
    Apr 6, 2004
  5. SMH
    Replies:
    2
    Views:
    266
Loading...

Share This Page