Developer forum

Forum » Templates » Convert HTML template into XML

Convert HTML template into XML

Dmitrij Jazel
Reply

Hello DW guys,

 

I have a situation here, I have just yet another page, with some paragraphs etc... Nothing special...

What I want is to give this page an xml page template - so I could use it as XML document.

But I can change only between HTML templates, and xml templates are not available...

 

I hope you get the idea of what I want get an XML version of a page. What could be the correct way to do it?

 

Kind regards,

Dmitrij

 


Replies

 
Morten Bengtson
Reply

I assume that you are using designs and layouts - not the old stylesheets implementation.

 

AFAIK there is no reliable way to get a clean XML output by using a page layout template.

If you just need some "almost XML" output, you can strip most of the HTML from all templates in use on that page.

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Blank page layout</title>
    </head>
    <body>
        <div id="content-main" class="dwcontent" title="Main content"></div>
    </body>
</html>

 

If you need actual XML, you can fetch any data stored in the database by using the Data Lists module.

A list of products or sitemap can be fetched as XML by using specific urls.

Some content is also available as XML through the RSS module.

 

/Morten

 
Morten Bengtson
Reply

You can switch between HTML and "almost XML" output by using a query string parameter, like ajax=true, and then make use of if defined in your templates...

 

<!--@If Defined(Server:Request.ajax)-->
<xml>XML content here</xml>
<!--@EndIf(Server:Request.ajax)-->

<!--@If Not Defined(Server:Request.ajax)-->
<div>HTML content here</div>
<!--@EndIf(Server:Request.ajax)-->

 

 

 
Dmitrij Jazel
Reply

Hej Morten,

 

Well the big plan is to make RSS feeds for News, but in the long run, not only that, also work with galleries that use XML as resource etc...

 

So I need to have a document corresponding to RSS spec. 2.0 for example...

And as far as I can see from your example, it will still <!DOCTYPE html> and that cannot be the case

as far as I know - there must be nothing except for

<?xml version="1.0" encoding="ISO-8859-1" ?>

as document declaration and spec declaration etc...

 

And RSS module, I also noticed that - this module just strips HTML and you can address the the page like XML document?

 

Maybe there are some other suggestions? :) If not RSS specifically is needed?

 

Regards,

Dmitrij

 
Morten Bengtson
Reply

I know exactly what you mean, but its just not possible in Dynamicweb. Even if you manage to format the markup like a valid xml document, it would still be served as HTML (text/html) and not XML (application/xml).

 

You can use one of the other options I mentioned before or export the content to XML documents by using Data Integration. If that doesn't solve your problem, I think you need some custom extension to serve the content as valid XML.

 

/Morten

 
Dmitrij Jazel
Reply

Hmm, alright...

Than your suggestion could be to use RSS module if just for this time we need to be able to feed RSS feeds to an RSS service isn't it?

 

I think custom module might be an overkill here :-) but I will try to see what I can do... thanks for help so far! :-)

 

Regards,

Dmitrij

 

 

You must be logged in to post in the forum