Welcome to WebmasterWorld Guest from 22.214.171.124
Forum Moderators: httpwebwitch
I've recently started a new project in ASP.Net, I've come across a little hurdle that I'm currently unsure of how to do.
I'm trying to keep this new CMS development away from databases as much as possible, although it will use a database for specific items.
I am wondering if the following is possible:
user logs into the site, decides to create a new 'page' via the cms's page bolt-on, the user enters the title, meta tags, description, then finally a chunk of html/content to design the page.
this information i wish to store in XML/XSLT file. obviously i don't know how much information will be placed into this CMS bolt on. it could be a simple
<h2>bla bla bla </h2>
<p>blah blah blah moo baa woof</p>
or a full range of <div>'s and <table>'s etc
is there a way for me to dump the content into a xml file and the relevant html into an XSLT dynamically?
I've searched google with no results that have helped, although a few other questions were answered, so some benefits.
Thanks for any responses.
I'm trying to keep this new CMS development away from databases as much as possible
I'm wondering why you would want to do that? Is it a technical requirement? Databases are fun. And they do a wonderful job of storing and retrieving blocks of HTML content.
is there a way for me to dump the content into a xml file and the relevant html into an XSLT dynamically
yes, using ASP.NET you can open a file, write to it, then save it.
I've searched google with no results that have helped
MSDN is overflowing with great tutorials to help you.
as for the dumping of html into xml, i know i can write to files etc, i was looking more of how i would go about the whole html into xml part.
the issue i had was basically i can't just dump user generated html into the xml file like i can a database, i need to (or so i believe) identify the html tags, build the xml file based on the textual content and then link each html tag into the xslt file. i believe i'm not explaining myself very well, i will take a good stab at it on the weekend.
Thank you for the msdn link, i can save text to xml files no issue, as i use xml files for configuration purposes within this cms site.
i may bite the bullet in the end and just build the content part of the cms using a database table. but its a fun challenge to find out if i can do it in xml.
Once again thank you for the response.
i can't just dump user generated html into the xml file like i can a database
Actually, you could.
Wrap the HTML in a CDATA node, to indicate that the value of the node is character data content. Then the wacky HTML entered by your users won't interfere with parsing the XML.
<title>my first web page</title>
<p>This is my first web page</p><font size="100">WOOT!</font><blockquote>I am so cool it hurts</blockquote>
I agree it would be quite a challenge to parse the HTML, put text nodes into XML and generate an XSLT to put it back together again. The advantage would be to allow people to enter a block of HTML, then use that page to generate similar pages with the same layout (a template, if you will).
But alas, the disadvantages... There are so many complications when parsing HTML. For instance, how would you handle an <img> node, or an <iframe> where the important content is an attribute, not a child node? And how would you handle badly-formed HTML, misnested tags, <script> tags, etc? Will you support SVG or <canvas>? Will you treat <style> as content data in the XML, or layout in the XSLT? And what about embedded Flash? and so on...
And then there's this gem:
<p>I am feeling <b>good</b> today.</p>
The "p" node has 3 children: a text node, followed by a "b" node with a text child, then another text node. Piecing that together into an XSLT layout would be a nightmare. You'd end up with 3 tiny chunks of content in your XML, and an XSLT that expects three bits of text to inject into it. A situation which doesn't do the document justice.
Sounds like an interesting project. Be careful not to get sidelined by inventing challenges where simpler solutions exist. That's my $0.02 :)