473,326 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Embedding HTML in XML

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.
Jul 20 '05 #1
2 6554
On Tue, 05 Oct 2004 12:12:37 -0400, Isaac Gerg
<is********@NOSPAM-adelphia.net> 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
Jul 20 '05 #2
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
<is********@NOSPAM-adelphia.net> 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.

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Atul Kshirsagar | last post by:
I am embedding python in my C++ application. I am using Python *2.3.2* with a C++ extention DLL in multi-threaded environment. I am using SWIG-1.3.19 to generate C++ to Python interface. Now to...
4
by: Alicia Haumann | last post by:
I accidentally sent this to webmaster@python.org, so this could be a duplicate if "webmaster" forwards it to this list. :{ Hi, there. Thanks for any help that can be offered. I've been...
2
by: Roose | last post by:
With some googling I have found these resources: http://docs.python.org/ext/win-dlls.html http://www.python.org/doc/faq/windows.html I have a large Win32/MFC/C/C++ application that has an...
8
by: Alan Lue | last post by:
Hi, I'm trying to set up a webpage so that I can view multiple HTML files from the same page. For example, you might go to http://example.com/lab_tests.html and be able to view lab1.html,...
2
by: John Dean | last post by:
Hi Could somebody, please tell me where I can find information about embedding Python into a C/C++ application. The example in the docs is rather simple. I am looking for something a bit more...
13
by: John Salerno | last post by:
I'm hoping someone can give me the basics for how to do very simple things with Python scripts from within my HTML. For example, I know that I can do this in PHP: <h1>Here is a header</h1>...
6
by: Qun Cao | last post by:
Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python...
3
by: Ollie Riches | last post by:
How do I embed a *.flv file (Flash Video) into an aspx page similar to embedding windows media player active x control? Cheers Ollie Riches
4
by: David Abrahams | last post by:
I'm seeing highly surprising (and different!) behaviors of PyImport_ImportModule on Linux and Windows when used in a program with python embedding. On Linux, when attempting to import a module...
2
by: John Grandy | last post by:
I am not having success embedding carriage return and line feed characters into a string and displaying them with an ASP.NET label. Is anyone getting either of the following to work ? ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.