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

J

John Salerno

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>
 
H

Harlan Messinger

John said:
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 ">".
 
R

richard

John Salerno said:
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.
 
J

John Salerno

richard said:
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.
 
B

Beauregard T. Shagnasty

richard said:
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.
 
A

Andy Dingley

John said:
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.
 
J

Jukka K. Korpela

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.
 
K

kdarling

John said:
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
 
R

richard

Andy Dingley said:
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.
 
A

Andy Dingley

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>.
 
J

Jukka K. Korpela

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.
 
A

Andy Dingley

Harlan said:
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
 
J

John Salerno

Jukka said:
Scripsit Harlan Messinger:


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.
 
H

Harlan Messinger

John said:
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.
 
H

Harlan Messinger

Jukka said:
Scripsit Andy Dingley:


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

Did they include it as a joke?
 
J

John Salerno

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.
 
J

John Salerno

Harlan said:
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! :)
 
K

kdarling

Harlan said:
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 ;-)
 
H

Harlan Messinger

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top