So I am quite upset that after working for a few hours on getting an
XML file format and XSL file that formats the XML data appropriatly,
only to find that if you store HTML code in your XML file (even in a
CDATA block), after the XML file is rendered, the HTML that was stored
in the XML file is not rendered, essentially put into the page as if it
had <pre> tags around it.
I know that someone is going to yell at me and say that the XML file
should only contain the content of the page, and that the formatting
should be done by the XSL, but I have a particluar use case for this.
Essentially I store HTML in my database, and want it to be transmitted
to the browser and rendered on the fly. As brief as I can say it is
like this:
I plan on using Javascript to download small XML files from my server
and place their contents, formatted accordingly, onto a page. The trick
here is that my XML file is basically a serialized dataset.
Additionally, I store HTML in my database for some fields. I want to
use XSL because I don't really care about the data in the XML file, I
just want it displayed (which is a perfect application for XML/XSL). I
have read that I could do something cheesy like matching the
A|P|BR|FONT tags, but that seems REALLY cheesy. Here is a bare bones of
my XML file:
<Data>
<RowDefinition>
<Field name=foo displaytype"Text|HTML|Dollars|Link|Image" />
... etc ...
</RowDefinition>
<Rows>
<Row>
<Value name=foo><![CDATA[A Value or maybe some HTML
code]]></Value>
... etc ...
</Row>
... There may or may not be more than one Row tag ...
</Rows>
</Data>
(I just typed this so it may not really be well formed BTW)
Is there something besides CDATA that I could use in this case? I can't
seem to find much usefull information on such a topic.
I have tried encoding the chars first, IE < and > , both with and
without the CDATA declerations, and I do get something different. With
the CDATA declaration, the > comes through as is, but without the
CDATA declaration, > comes through as >. I was really hopin that
something like this would work, damn...
My other (and more dreaded option) is to use a javascript XMLDom and
parse the contents out manually and set certain parts of a
spans.InnerHTML property to the value from the DOM, but I really don't
want to have to write recursive javascript functions, and design HTML
that responds that well to this type of thing. I guess I would have had
a hard time getting the XSL to render the XML via javascript, so
writing some XMLDom javascript code may be my only option...
Any ideas on this, or maybe if you don't think that this is possible,
if someone could send me a good, browser concious, reference guide to
the various Javascript XML Doms out there, it would be greatly
appreciated...
Thanks for your time in advance!
Andy Baldwin