how to include xml code as content in an html file?

Discussion in 'HTML' started by John Salerno, Oct 4, 2006.

  1. John Salerno

    John Salerno Guest

    Hi all. Been a while since I was in here, but I'm back on the HTML horse
    for now. :)

    Anyway, can someone tell me how to include XML data as text in an HTML
    file? I don't know if that makes sense, because I'm not sure of the
    right terms to use (data, content, text, etc.) But here's what I have,
    and instead of just showing all this as text, it omits all of the XML tags.

    Thanks!



    <code><pre>#design layout in a separate XML file
    <?xml version="1.0" encoding="cp1252"?>
    <resource>
    <object class="wxFrame" name="mainFrame">
    <title>My Frame</title>
    <object class="wxPanel" name="panel">
    <object class="wxFlexGridSizer">
    <cols>2</cols>
    <rows>3</rows>
    <vgap>5</vgap>
    <hgap>5</hgap>
    <object class="sizeritem">
    <object class="wxStaticText" name="label1">
    <label>First name:</label>
    </object>
    </object>
    <object class="sizeritem">
    <object class="wxTextCtrl" name="text1"/>
    </object>
    <object class="sizeritem">
    <object class="wxStaticText" name="label2">
    <label>Last name:</label>
    </object>
    </object>
    <object class="sizeritem">
    <object class="wxTextCtrl" name="text2"/>
    </object>
    <object class="spacer">
    <size>0,0</size>
    </object>
    <object class="sizeritem">
    <object class="wxButton" name="btn">
    <label>Submit</label>
    </object>
    </object>
    </object>
    </object>
    </object>
    </resource></pre></code>
     
    John Salerno, Oct 4, 2006
    #1
    1. Advertising

  2. John Salerno wrote:
    > Hi all. Been a while since I was in here, but I'm back on the HTML horse
    > for now. :)
    >
    > Anyway, can someone tell me how to include XML data as text in an HTML
    > file? I don't know if that makes sense, because I'm not sure of the
    > right terms to use (data, content, text, etc.) But here's what I have,
    > and instead of just showing all this as text, it omits all of the XML tags.


    Certainly, just as the browser "omits" "<p>" and "</table>". They're
    tags, not displayable content. The difference is that while the browser
    interprets HTML tags in some visually apparent manner, it doesn't know
    what to do with your XML tags, so it ignores them altogether.

    If you want tags, whether XML or HTML, to appear literally in your
    content you need to use "&lt;" (i.e., less than) instead of "<" and
    "&gt;" (greater than) instead of ">".
     
    Harlan Messinger, Oct 4, 2006
    #2
    1. Advertising

  3. John Salerno

    richard Guest

    "John Salerno" <> wrote in message
    news:gFSUg.67$...
    > Hi all. Been a while since I was in here, but I'm back on the HTML horse
    > for now. :)
    >
    > Anyway, can someone tell me how to include XML data as text in an HTML
    > file? I don't know if that makes sense, because I'm not sure of the right
    > terms to use (data, content, text, etc.) But here's what I have, and
    > instead of just showing all this as text, it omits all of the XML tags.
    >
    > Thanks!


    Mainly because you have declared that it is html, not xhtml, which are two
    different things.
    You might be able to get away with it with the code in a linked external
    file.
     
    richard, Oct 4, 2006
    #3
  4. John Salerno

    John Salerno Guest

    richard wrote:
    >
    > "John Salerno" <> wrote in message
    > news:gFSUg.67$...
    >> Hi all. Been a while since I was in here, but I'm back on the HTML
    >> horse for now. :)
    >>
    >> Anyway, can someone tell me how to include XML data as text in an HTML
    >> file? I don't know if that makes sense, because I'm not sure of the
    >> right terms to use (data, content, text, etc.) But here's what I have,
    >> and instead of just showing all this as text, it omits all of the XML
    >> tags.
    >>
    >> Thanks!

    >
    > Mainly because you have declared that it is html, not xhtml, which are
    > two different things.
    > You might be able to get away with it with the code in a linked external
    > file.
    >


    But is there really no way to represent XML data in an HTML page? Seems
    like something that would have become an issue long, long ago.
     
    John Salerno, Oct 4, 2006
    #4
  5. richard wrote:

    > Mainly because you have declared that it is html, not xhtml, which are two
    > different things.


    ...and which has nothing to do with the OP's question.

    --
    -bts
    -Motorcycles defy gravity; cars just suck
     
    Beauregard T. Shagnasty, Oct 4, 2006
    #5
  6. John Salerno

    Andy Dingley Guest

    John Salerno wrote:

    > Anyway, can someone tell me how to include XML data as text in an HTML
    > file?


    You don't. There have been techniques in the past (M$ XML data islands
    and the <XML> tag) to do this and there will be XHTML techniques
    (namespaces) to do it with in the future, but right at the moment it's
    impractical and frowned upon. A better way is to use JavaScript,
    borrow some standard AJAX code, and load the XML separately by using a
    scripted object within the page to load the XML through a separate HTTP
    transaction.
     
    Andy Dingley, Oct 4, 2006
    #6
  7. Scripsit Harlan Messinger:

    > If you want tags, whether XML or HTML, to appear literally in your
    > content you need to use "&lt;" (i.e., less than) instead of "<" and
    > "&gt;" (greater than) instead of ">".


    Except that you never _need_ to escape ">" (though you're allowed) and you
    _do_ need to escape "&" quite often (e.g., always in XHTML).

    But if this is what the OP wanted (the original question has several
    interpretations), then it's time to remind: if you needed to ask for help in
    displaying markup on a web page, you are not qualified to give others advice
    on using markup, as you apparently meant to.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Oct 5, 2006
    #7
  8. John Salerno

    Guest

    John Salerno wrote:
    > Anyway, can someone tell me how to include XML data as text in an HTML
    > file? I don't know if that makes sense, because I'm not sure of the
    > right terms to use (data, content, text, etc.) But here's what I have,
    > and instead of just showing all this as text, it omits all of the XML tags.


    To display XML as text, for IE6, wrap it all in between <xmp> and
    </xmp>.

    Cheers, Kev
     
    , Oct 5, 2006
    #8
  9. John Salerno

    richard Guest

    "Andy Dingley" <> wrote in message
    news:...
    >
    > John Salerno wrote:
    >
    >> Anyway, can someone tell me how to include XML data as text in an HTML
    >> file?

    >
    > You don't. There have been techniques in the past (M$ XML data islands
    > and the <XML> tag) to do this and there will be XHTML techniques
    > (namespaces) to do it with in the future, but right at the moment it's
    > impractical and frowned upon. A better way is to use JavaScript,
    > borrow some standard AJAX code, and load the XML separately by using a
    > scripted object within the page to load the XML through a separate HTTP
    > transaction.
    >


    Gee beau, ain't this the same thing I said?
    He just explained it better.
     
    richard, Oct 5, 2006
    #9
  10. richard wrote:

    > "Andy Dingley" <> wrote in message
    > news:...
    >>
    >> John Salerno wrote:
    >>
    >>> Anyway, can someone tell me how to include XML data as text in an HTML
    >>> file?

    >>
    >> You don't. There have been techniques in the past (M$ XML data
    >> islands and the <XML> tag) to do this and there will be XHTML
    >> techniques (namespaces) to do it with in the future, but right at
    >> the moment it's impractical and frowned upon. A better way is to
    >> use JavaScript, borrow some standard AJAX code, and load the XML
    >> separately by using a scripted object within the page to load the
    >> XML through a separate HTTP transaction.

    >
    > Gee beau, ain't this the same thing I said?


    Not even close.

    > He just explained it better.


    --
    -bts
    -Motorcycles defy gravity; cars just suck
     
    Beauregard T. Shagnasty, Oct 5, 2006
    #10
  11. John Salerno

    Andy Dingley Guest

    wrote:

    > To display XML as text, for IE6, wrap it all in between <xmp> and
    > </xmp>.


    Please, don't use <xmp> That one was obsolete and deprecated even
    before <XML>.
     
    Andy Dingley, Oct 5, 2006
    #11
  12. Scripsit Andy Dingley:

    > Please, don't use <xmp> That one was obsolete and deprecated even
    > before <XML>.


    And even before HTML. The _first_ HTML specification ever mentions <xmp>
    only as obsolete and deprecated.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Oct 5, 2006
    #12
  13. John Salerno

    Andy Dingley Guest

    Harlan Messinger wrote:

    > If you want tags, whether XML or HTML, to appear literally in your
    > content you need to use "&lt;" (i.e., less than) instead of "<" and
    > "&gt;" (greater than) instead of ">".


    Sorry, I'd totally misunderstood the OP's question. Harlan is right
    here, assuming that you do want the source code of the XML to be
    visible on the page. I thought they'd intended to use the XML as data.

    Encode > as well as <, or else you'll go mad trying to keep track. You
    don't _always_ have to encode such things, but it's certainly easier
    (for humans) if you do
     
    Andy Dingley, Oct 5, 2006
    #13
  14. John Salerno

    John Salerno Guest

    Jukka K. Korpela wrote:
    > Scripsit Harlan Messinger:
    >
    >> If you want tags, whether XML or HTML, to appear literally in your
    >> content you need to use "&lt;" (i.e., less than) instead of "<" and
    >> "&gt;" (greater than) instead of ">".

    >
    > Except that you never _need_ to escape ">" (though you're allowed) and
    > you _do_ need to escape "&" quite often (e.g., always in XHTML).
    >
    > But if this is what the OP wanted (the original question has several
    > interpretations), then it's time to remind: if you needed to ask for
    > help in displaying markup on a web page, you are not qualified to give
    > others advice on using markup, as you apparently meant to.
    >


    Are you talking to me? I don't understand what you mean. I'm not trying
    to give advice to anyway.

    I get the feeling I'm missing some posts for some reason. The one from
    Scripsit that is quoted above, for example, does not appear in my
    newsreader.
     
    John Salerno, Oct 5, 2006
    #14
  15. John Salerno wrote:
    > Jukka K. Korpela wrote:
    >> Scripsit Harlan Messinger:
    >>
    >>> If you want tags, whether XML or HTML, to appear literally in your
    >>> content you need to use "&lt;" (i.e., less than) instead of "<" and
    >>> "&gt;" (greater than) instead of ">".

    >>
    >> Except that you never _need_ to escape ">" (though you're allowed) and
    >> you _do_ need to escape "&" quite often (e.g., always in XHTML).
    >>
    >> But if this is what the OP wanted (the original question has several
    >> interpretations), then it's time to remind: if you needed to ask for
    >> help in displaying markup on a web page, you are not qualified to give
    >> others advice on using markup, as you apparently meant to.
    >>

    >
    > Are you talking to me? I don't understand what you mean. I'm not trying
    > to give advice to anyway.
    >
    > I get the feeling I'm missing some posts for some reason. The one from
    > Scripsit that is quoted above, for example, does not appear in my
    > newsreader.


    LOL. It isn't from Scripsit. "Scripsit" is the Latin third-person
    singular preterite form of "scribere" meaning "to write". "Harlan
    Messinger wrote" is what Jukka wrote.

    I don't know why you didn't get my message, but the important part of
    what I wrote is above.
     
    Harlan Messinger, Oct 5, 2006
    #15
  16. Jukka K. Korpela wrote:
    > Scripsit Andy Dingley:
    >
    >> Please, don't use <xmp> That one was obsolete and deprecated even
    >> before <XML>.

    >
    > And even before HTML. The _first_ HTML specification ever mentions <xmp>
    > only as obsolete and deprecated.


    Did they include it as a joke?
     
    Harlan Messinger, Oct 5, 2006
    #16
  17. John Salerno

    John Salerno Guest

    Andy Dingley wrote:
    > Harlan Messinger wrote:
    >
    >> If you want tags, whether XML or HTML, to appear literally in your
    >> content you need to use "&lt;" (i.e., less than) instead of "<" and
    >> "&gt;" (greater than) instead of ">".


    Thanks guys! This seems to be the easiest method for now. I don't know
    anything about JavaScript yet, so I don't want to mess with that.
    Besides, it's easy to do a find/replace when I need to change these back
    to "<", if ever.
     
    John Salerno, Oct 5, 2006
    #17
  18. John Salerno

    John Salerno Guest

    Harlan Messinger wrote:
    > John Salerno wrote:
    >> Jukka K. Korpela wrote:
    >>> Scripsit Harlan Messinger:
    >>>
    >>>> If you want tags, whether XML or HTML, to appear literally in your
    >>>> content you need to use "&lt;" (i.e., less than) instead of "<" and
    >>>> "&gt;" (greater than) instead of ">".
    >>>
    >>> Except that you never _need_ to escape ">" (though you're allowed)
    >>> and you _do_ need to escape "&" quite often (e.g., always in XHTML).
    >>>
    >>> But if this is what the OP wanted (the original question has several
    >>> interpretations), then it's time to remind: if you needed to ask for
    >>> help in displaying markup on a web page, you are not qualified to
    >>> give others advice on using markup, as you apparently meant to.
    >>>

    >>
    >> Are you talking to me? I don't understand what you mean. I'm not
    >> trying to give advice to anyway.
    >>
    >> I get the feeling I'm missing some posts for some reason. The one from
    >> Scripsit that is quoted above, for example, does not appear in my
    >> newsreader.

    >
    > LOL. It isn't from Scripsit. "Scripsit" is the Latin third-person
    > singular preterite form of "scribere" meaning "to write". "Harlan
    > Messinger wrote" is what Jukka wrote.


    Woops, that's what I get for just glancing at the first word! :)
     
    John Salerno, Oct 5, 2006
    #18
  19. John Salerno

    Guest

    Harlan Messinger wrote:
    > Jukka K. Korpela wrote:
    > > Scripsit Andy Dingley:
    > >
    > >> Please, don't use <xmp> That one was obsolete and deprecated even
    > >> before <XML>.

    > >
    > > And even before HTML. The _first_ HTML specification ever mentions <xmp>
    > > only as obsolete and deprecated.

    >
    > Did they include it as a joke?


    It's the only tag that does what's often needed. Yes, it's
    obsolete/deprecated (depending on which standard you use), but so are
    CENTER, FONT and U, all of which will be around a long long time.

    XMP is still supported by IE, Opera, Mozilla, etc. It's just too handy
    to die. So unless you're writing a browser and don't want to implement
    it and hate people who use it, or are just anal-retentive, then I see
    no reason not to take advantage of it.. at least for personal use :)

    Kev (I love standards, been programming since 1978, but have seen a lot
    of things come and go that shouldn't have ;-)
     
    , Oct 5, 2006
    #19
  20. wrote:
    > Harlan Messinger wrote:
    >> Jukka K. Korpela wrote:
    >>> Scripsit Andy Dingley:
    >>>
    >>>> Please, don't use <xmp> That one was obsolete and deprecated even
    >>>> before <XML>.
    >>> And even before HTML. The _first_ HTML specification ever mentions <xmp>
    >>> only as obsolete and deprecated.

    >> Did they include it as a joke?

    >
    > It's the only tag that does what's often needed. Yes, it's
    > obsolete/deprecated (depending on which standard you use), but so are
    > CENTER, FONT and U, all of which will be around a long long time.


    What I meant was, was it a joke to label something, in a specification,
    as obsolete or deprecated when there had never been a previous version
    of the specification in which it could have been included as a living,
    breathing component.
     
    Harlan Messinger, Oct 5, 2006
    #20
    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. Cloud Burst
    Replies:
    11
    Views:
    1,035
  2. hazz
    Replies:
    6
    Views:
    49,637
    SkyUCHC
    Jun 9, 2010
  3. Rui Maciel
    Replies:
    1
    Views:
    615
    Martin Honnen
    Nov 2, 2005
  4. Tom
    Replies:
    8
    Views:
    679
    Adrienne Boswell
    Feb 13, 2007
  5. Andreas Bogenberger
    Replies:
    3
    Views:
    934
    Andreas Bogenberger
    Feb 22, 2008
Loading...

Share This Page