I'm utterly confounded, and can only find info on parsing CDATA _from_ an XML
file, not _writing_ CDATA in XML formatted output.
---------------------------------
What I am currently generating :
<events>
<day thedate="15/10/2004" text1="var1" text2="var2" /></day>
. . .
</events>
---------------------------------
What I need to generate (word wrap aside) :
<events>
<day thedate="15/10/2004" text1="var1" text2="var2" /><![CDATA[
$details_field_here ]]></day>
. . .
</events>
---------------------------------
I can't figure out how to take the MySQL field containing HTML and insert it
into a CDATA segment as required.
---------------------------------
The code I have so far :
$root = $doc->add_root("events");
while (list($thedate, $var1, $var2, $details) = mysql_fetch_row($result)) {
$record = $root->new_child("day", "");
$record->set_attribute("thedate", $thedate);
$record->set_attribute("text1", $var1);
$record->set_attribute("text2", $var2);
// Stuck here, trying to insert $details CDATA
}
I've seen the short manual page about create_cdata_section, but nothing that's
actually helpful. I must be missing something in all my Googling and
manual-reading, but I'm stumped.
Any and all advice will be greatly appreciated. TIA ! 2 2595 us****@isotopeREEMOOVEmedia.com wrote: I've seen the short manual page about create_cdata_section, but nothing that's actually helpful. I must be missing something in all my Googling and manual-reading, but I'm stumped.
Any and all advice will be greatly appreciated. TIA !
Untested, but this should do it:
....
$record = $root->new_child("day", "");
$record->set_attribute("thedate", $thedate);
$record->set_attribute("text1", $var1);
$record->set_attribute("text2", $var2);
// Add $details CDATA
$cdata = $doc->create_cdata_section($details);
$record->append_child($cdata);
....
JW
On Mon, 17 Jan 2005 10:16:58 +0100, Janwillem Borleffs <jw@jwscripts.com> wrote: us****@isotopeREEMOOVEmedia.com wrote: I've seen the short manual page about create_cdata_section, but nothing that's actually helpful. I must be missing something in all my Googling and manual-reading, but I'm stumped.
Any and all advice will be greatly appreciated. TIA !
Untested, but this should do it:
... $record = $root->new_child("day", ""); $record->set_attribute("thedate", $thedate); $record->set_attribute("text1", $var1); $record->set_attribute("text2", $var2); // Add $details CDATA $cdata = $doc->create_cdata_section($details); $record->append_child($cdata); ...
JW
Thanks, JW ! That's exactly right. I didn't realize that append_child was
necessary here.
This is a huge help -- thanks so much. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Isaac Councill |
last post by:
Hello,
This seems like a newbie question, but I couldn't find the answer on
google.
I've been using xsl to transform rdf files into runnable
programs in another (non-markup) language. It's...
|
by: Dimitre Novatchev |
last post by:
You seem to be unaware of the xslt processing which uses the built-in
rules in the absence of templates that match some selected node.
http://www.w3.org/TR/xslt#built-in-rule
According to the...
|
by: Yasutaka Ito |
last post by:
Hi folks!
I have a DataSet, which I'm writing into XML using the DataSet.WriteXML()
method. Now, I want to write the cell's data/text as CDATA, when it is
written into an XML. For example, I...
|
by: Tomas Vera |
last post by:
Hello All,
I'm having trouble writing some special characters to an XML file.
I need to output a XMLSS formatted file to be read by Excel.
In some cells there will be some text that contains...
|
by: chris |
last post by:
Confused somewhat xml newbie. I'm trying to output xml with a CDATA
section, using saxutils.XMLGenerator, but the output contains escaped
'<' and '>' and '&' from the CDATA element. Shouldn't it...
|
by: troppfigo |
last post by:
I have this example of xml
<?xml version="1.0"?>
<xml>
<!]>
</xml>
I want to extract the contained data from <body> tag using an xslt
transformation.
I want to obtain this
|
by: Steveino |
last post by:
Hello,
Just wondering if anyone could shed any light on this, it's probably me just
being silly...
I have a dataset that I've used to create an XmlDataDocument, in order to
apply XSL. The XSL...
|
by: RolfK |
last post by:
Hello Experts,
I have a small problem with copy of CDATA sections.
(I'm using XSLT2.0 )
My output target is defined as txt.
In my xml source is a CDATA section to be put as it is into the...
|
by: dkyadav80 |
last post by:
Hi sir,
I'm new about xml, javascript. I have two selection field(html) first is city and second is state. the city and state values should be store in xml file. when user select city then all...
|
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: 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: 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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |