Hello,
I have an XML file that looks like this
<?xml version="1.0" encoding="UTF-8"?>
<discography>
<CD>
<title>Moonlight</title>
<year>1974</year>
<description>
<p>Description <span>of</spanthe CD</p>
<p>More description of the CD</p>
<p>Another <b>paragraph</bof the CD</p>
</description>
<item>
<track>Forever</track>
<track>Again</track>
<track>Alone</track>
</item>
</CD>
</discography>
The HTML output should look like this:
<h1>Moonlight</h1>
<h3>1974</h3>
<p>Description <span>of</spanthe CD</p>
<p>More description of the CD</p>
<p>Another <b>paragraph</bof the CD</p>
<ul>
<li>Forever</li>
<li>Again</li>
<li>Alone</li>
</ul>
I've manage to create the HTML but i'm stock with the xml
<description>.
I found a solution using CDATA, but i'm not sure if it's an elegant
solution. I've read that the CDATA was not ment to be used for that
purpose.
As a programmer, i always try to create code that is ok and elegant.
But in this case, the CDATA works perfectly and it's so simple. I feel
like if don't use the CDATA solution i would need to create a
complicated function to extract all those HTML tags inside the xml
<descriptiontaq.
What should i do? Any suggestions?
Solution:
<description>
<![CDATA[
<p>Description <span>of</spanthe CD</p>
<p>More description of the CD</p>
<p>Another <b>paragraph</bof the CD</p>
]]>
</description>
Thanks in advance for all your advice
Marco 7 3368
<![CDATA[]]is just text content, as far as any properly written XML
application is concerned. It's an alternative to individually escaping
characters, <![CDATA[<&>]]is precisely equivalent to the <&>
sequence. That's all it is.
If you think you need to put XML/HTML content into a CDATA section, you
are almost undoubtedly wrong. You should be able to just produce the
proper document structure directly.
You didn't say what tools you're using, so it's hard to give you
specific advice... but XSLT would have no trouble generating your
desired output, nor should any other halfway reasonable XML tooling.
On May 9, 11:35 am, "Joseph J. Kesselman" <keshlam-nos...@comcast.net>
wrote:
<![CDATA[]]is just text content, as far as any properly written XML
application is concerned. It's an alternative to individually escaping
characters, <![CDATA[<&>]]is precisely equivalent to the <&>
sequence. That's all it is.
If you think you need to put XML/HTML content into a CDATA section, you
are almost undoubtedly wrong. You should be able to just produce the
proper document structure directly.
You didn't say what tools you're using, so it's hard to give you
specific advice... but XSLT would have no trouble generating your
desired output, nor should any other halfway reasonable XML tooling.
Thanks for the explanation. Im using SimpleXML and PHP.
Marco
On May 9, 11:35 am, "Joseph J. Kesselman" <keshlam-nos...@comcast.net>
wrote:
<![CDATA[]]is just text content, as far as any properly written XML
application is concerned. It's an alternative to individually escaping
characters, <![CDATA[<&>]]is precisely equivalent to the <&>
sequence. That's all it is.
If you think you need to put XML/HTML content into a CDATA section, you
are almost undoubtedly wrong. You should be able to just produce the
proper document structure directly.
You didn't say what tools you're using, so it's hard to give you
specific advice... but XSLT would have no trouble generating your
desired output, nor should any other halfway reasonable XML tooling.
Thanks for the explanation. I'm using SimpleXML and PHP to read the
xml file. It's all good except the <descriptiontag with all those
embedded HTML tags that i'm stock with.
I've search and search and found CDATA as a probable solution but was
never sure of it. Now that i'm reading you, it's obvious that it's not
the path to take. Maybe you could guide me on how to generate proper
HTML using simpleXML in PHP.
Thanks
Marco
SM wrote:
Maybe you could guide me on how to generate proper
HTML using simpleXML in PHP.
I haven't used either simpleXML or PHP, so I'll have to refer this to
someone else.
On May 9, 12:59 pm, "Joseph J. Kesselman" <keshlam-nos...@comcast.net>
wrote:
SM wrote:
Maybe you could guide me on how to generate proper
HTML using simpleXML in PHP.
I haven't used either simpleXML or PHP, so I'll have to refer this to
someone else.
ok. Thanks
On May 9, 1:46 pm, SM <servandomont...@gmail.comwrote:
On May 9, 12:59 pm, "Joseph J. Kesselman" <keshlam-nos...@comcast.net>
wrote:
SM wrote:
Maybe you could guide me on how to generate proper
HTML using simpleXML in PHP.
I haven't used either simpleXML or PHP, so I'll have to refer this to
someone else.
ok. Thanks
Got it! After a couple of hours researching i finally found a
solution. And elegant solution and one that, as a programmer, i feel
confortable using.
The trick is to use the funtion in PHP asXML(); This function returns
a well-formed XML string based on SimpleXML element
Here's a good article on how it works (search for the paragraph 'Edge
Conditions')
I've tried it and it works!
Marco
On May 9, 6:05 pm, SM <servandomont...@gmail.comwrote:
On May 9, 1:46 pm, SM <servandomont...@gmail.comwrote:
On May 9, 12:59 pm, "Joseph J. Kesselman" <keshlam-nos...@comcast.net>
wrote:
SM wrote:
Maybe you could guide me on how to generate proper
HTML using simpleXML in PHP.
I haven't used either simpleXML or PHP, so I'll have to refer this to
someone else.
ok. Thanks
Got it! After a couple of hours researching i finally found a
solution. And elegant solution and one that, as a programmer, i feel
confortable using.
The trick is to use the funtion in PHP asXML(); This function returns
a well-formed XML string based on SimpleXML element
Here's a good article on how it works (search for the paragraph 'Edge
Conditions')
I've tried it and it works!
Marco
Opppsss ! to excited, i forgot the article link: http://devzone.zend.com/node/view/id/688 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Frank Millman |
last post by:
Hi all
I need to generate potentially large reports from a database, and I
want to offer the option of print preview before actually printing
(using wxPython). I figure that the best way to...
|
by: mcsdguru |
last post by:
When a user clicks File exit in a VB.NET application.........
What would be the best way to end the application after the normal cleanup
stuff specific to the application?
|
by: Andre Ranieri |
last post by:
I'm building an multiform Windows application that I anticipate will grow to
contain many forms. I would appreciate some "best practices" advice on the
cleanest way to call one form from another....
|
by: Anil Pundhir |
last post by:
What is the best way to pass data to a web service.
The client(to send data) has .net environment and also the server on which
the web service is hosted also has the .net environment.
Should I...
|
by: news.demon.nl |
last post by:
Hi,
I hope someone can give me some advice on which form of security i can use
best in this scenario:
I have a free application that everbody on the internet can download.
It calls a...
|
by: Gladen Blackshield |
last post by:
Hello All!
Still very new to PHP and I was wondering about the easiest and simplest way
to go about doing something for a project I am working on. I would simply
like advice on what I'm asking...
|
by: Brian Cryer |
last post by:
I've developed software (vb.net) that renders maps using svg. My manager
would like this "mapping component" to be migrated into a library so it can
easily be used by other web based applications....
|
by: shapper |
last post by:
Hello,
I am creating a form that includes a few JQuery scripts and TinyMCE
Editor:
http://www.27lamps.com/Beta/Form/Form.html
I am having a few problems with my CSS:
1. Restyling the Select
|
by: SM |
last post by:
Hello,
I have a index.php template (2 columns). The right columns contains a
bunch of links (interviews, poems, etc...) The left columns contains
the actual article.
So if I click on a link on...
|
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...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |