Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Embedding HTML in XML

Reply
Thread Tools

Embedding HTML in XML

 
 
Isaac Gerg
Guest
Posts: n/a
 
      10-05-2004
I have a server running PHP on linux. For a website, I want to have the
webdocuments stored in XML, then parsed by PHP code to add the
appropriate titles, headers, menus, etc.

So, I want to embed some HTML into XML. Can I do this? If so, what
functions do I use to parse this? Below is an example XML doc.

<xml>
<title>Document Title</title>
<menu level="2">
<item>Home</item>
<item>Products</item>
</menu>
<content>
<p>
Now introduction, our <B>NEW</B> product line!
</content>
</xml>


The php will parse title and menu easily... but how i can i get it to
return 'content' as a string which includes all that HTML?

Any help deeply appreciated.
 
Reply With Quote
 
 
 
 
Andy Dingley
Guest
Posts: n/a
 
      10-06-2004
On Tue, 05 Oct 2004 12:12:37 -0400, Isaac Gerg
<(E-Mail Removed)> wrote:

>So, I want to embed some HTML into XML. Can I do this?


Yes. There are several ways to do it. You will find it useful to study
RSS, which had to address a similar problem (unfortunately not
particularly well). There's an interesting overview of it here
http://diveintomark.org/archives/200...compatible-rss
You can probably even find PHP code to help you do this, by looking at
RSS tools

If you want to embed HTML, then you have two main options; encoding
and CDATA. Encoding is often simpler.

[...]
<content>
&lt;p&gt;
Now introduction, our &lt;B&gt;NEW&lt;/B&gt; product line!
</content>
[...]

Note that encoding the HTML entity reference "&lt;" will need to
appear as "&amp;lt;"


or as CDATA
[...]
<content><![CDATA[
<p>
Now introduction, our <B>NEW</B> product line!
]]></content>
[...]

Note that the sequence ]]> in your HTML (an embedded CDATA section)
will need some special handling too.



If you can abandon HTML in favour of XHTML though, there's a much
better solution available; namespacing. If you control the HTML part
of the process yourself, I'd see this as a good reason to switch to
XHTML.

--
Smert' spamionam
 
Reply With Quote
 
 
 
 
Isaac Gerg
Guest
Posts: n/a
 
      10-07-2004
I choose to use CDATA for those intersted. See http://www.gergltd.com

Isaac

Andy Dingley wrote:

> On Tue, 05 Oct 2004 12:12:37 -0400, Isaac Gerg
> <(E-Mail Removed)> wrote:
>
>
>>So, I want to embed some HTML into XML. Can I do this?

>
>
> Yes. There are several ways to do it. You will find it useful to study
> RSS, which had to address a similar problem (unfortunately not
> particularly well). There's an interesting overview of it here
> http://diveintomark.org/archives/200...compatible-rss
> You can probably even find PHP code to help you do this, by looking at
> RSS tools
>
> If you want to embed HTML, then you have two main options; encoding
> and CDATA. Encoding is often simpler.
>
> [...]
> <content>
> &lt;p&gt;
> Now introduction, our &lt;B&gt;NEW&lt;/B&gt; product line!
> </content>
> [...]
>
> Note that encoding the HTML entity reference "&lt;" will need to
> appear as "&amp;lt;"
>
>
> or as CDATA
> [...]
> <content><![CDATA[
> <p>
> Now introduction, our <B>NEW</B> product line!
> ]]></content>
> [...]
>
> Note that the sequence ]]> in your HTML (an embedded CDATA section)
> will need some special handling too.
>
>
>
> If you can abandon HTML in favour of XHTML though, there's a much
> better solution available; namespacing. If you control the HTML part
> of the process yourself, I'd see this as a good reason to switch to
> XHTML.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedding an html application into a static html page jeff_j_dunlap@yahoo.com HTML 5 01-09-2008 04:49 PM
Embedding html inside html (that old chestnut) DartGuru HTML 4 10-23-2007 02:47 PM
Embedding Gifs, animated gifs and other html pages into HTML winstontuck@gmail.com HTML 1 09-13-2006 11:11 AM
embedding xml in xml as non-xml :) Mark Van Orman XML 5 09-15-2004 05:57 AM
Embedding xml as remote obects into static html Kevin HTML 1 12-17-2003 01:49 PM



Advertisments