aspose file tools
The moose likes XML and Related Technologies and the fly likes HTML file within an XML file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "HTML file within an XML file" Watch "HTML file within an XML file" New topic
Author

HTML file within an XML file

Dmitry Shekhter
Greenhorn

Joined: Feb 21, 2001
Posts: 26
Hi all,
My question is this. Is it possible to embed an HTML page as an element within an XML document, like if I wanted to have something like
<site>
<name>Fubar</name>
<htmlpage> ...this is where i'd want the html page </htmlpage>
</site>
How would this work/look?
I hope my question makes sense.
Thanks
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Yes, it is possible. However, you need to make sure that the resulting XML is still wellformed (which HTML is not, so you must encode certain special characters, fix <br> tags with not closing counterpart, etc.)


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Dmitry Shekhter
Greenhorn

Joined: Feb 21, 2001
Posts: 26
Do I still have to format the HTML if i declare the element containing it as CDATA?
Thanks
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
It should be ok as long as your HTML doesn't include the "]]>" string closing the CDATA block.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: HTML file within an XML file
 
Similar Threads
regexp problem - smallest possible match on string
XML -vs- HTML or others
How to get at frames using HtmlUnit?
Display xml file in Pane
Navigation of XML records