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("even ts");
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_se ction, 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 2614 us****@isotopeR EEMOOVEmedia.co m wrote: I've seen the short manual page about create_cdata_se ction, 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_s ection($details );
$record->append_child($ cdata);
....
JW
On Mon, 17 Jan 2005 10:16:58 +0100, Janwillem Borleffs <jw@jwscripts.c om> wrote: us****@isotope REEMOOVEmedia.c om wrote: I've seen the short manual page about create_cdata_se ction, 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_s ection($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 been great except for a
minor hiccup - all text within CDATA blocks shows up at the end of my
output files without being invited.
I think I've boiled it down to a specific problem, but I'd like to better
understand why it is a problem at all.
|
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 XSLT processing model:
http://www.w3.org/TR/xslt#section-Processing-Model
the root node will be processed by a built-in rule, because you do not
|
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 want the XML output as follows:
<root>
<myElement><!]></myElement>
</root>
|
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 CR-LF pairs such
as
"this is a long entry\r\nThis is the secondline".
I'm building an XML document to represent my Excel data. This is
|
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 be spit out
intact?
Here's code and output:
from xml.sax import saxutils
import sys
handler = saxutils.XMLGenerator(sys.stdout)
| |
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 reformats the XML to another format (still XML, not HTML).
This works fine, but whatever I do, I can't get the finally output section to
have CDATA elements. I've added a cdata-section-elements tag into the xsl
file, but it doesn't seem to have...
|
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 output
text file.
This CDATA will be copied to the output by xsl:value-of or xsl:copy-
of.
|
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 city values should display in city selection field and when user select any one city value then this state of this city should be display auto in state
selection field without user selection. please solve my prolem.
Thank you.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |