473,396 Members | 1,756 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,396 software developers and data experts.

How to set an string element's value to a CDATA block?

I've got a class hierarchy generated from a .xsd schema file using the
XSD.EXE tool. One of the elements will have its "inner text" set to a CDATA
block. The XSD.EXE tool exposed a "Value" property on that element to allow
setting that inner text. After I create the object hierarchy and specify all
the appropriate elements, attributes, etc., I serialize the objects to a .xml
file using XmlSerializer.

If I simply specify the "element.Value" property to the string data (what
should go inside the CDATA), the string simply becomes the inner text - it's
not wrapped in the CDATA delimiters. So it would appear that the classes
generated by XSD.EXE either can't or don't have enough information to
automatically wrap the data in a CDATA.

If I try to manually wrap the string data by specifying element.Value as
"<![CDATA[" + string + "]]>", the '<' and '>' characters get encoded as < and
respectively when I serialize the object to an XML file.
Is there a way to get the behavior I need - that is, the string data is
properly wrapped in the CDATA markers to create a valid element with CDATA
inner text?

Thanks,

Donnie

Aug 23 '06 #1
1 4004
(Part of this got mangled when posting...)

The problem that happens when I try to manually wrap the string data in the
normal CDATA delimiters is that the "less than" symbol at the start of the
CDATA section gets converted during serialization to the "& l t ;" entity,
and correspondingly with the "greater than" symbol that ends the CDATA
section.

This obviously makes it an invalid CDATA section and is not what I want.

Thanks again,

Donnie

"soccerdad" wrote:
I've got a class hierarchy generated from a .xsd schema file using the
XSD.EXE tool. One of the elements will have its "inner text" set to a CDATA
block. The XSD.EXE tool exposed a "Value" property on that element to allow
setting that inner text. After I create the object hierarchy and specify all
the appropriate elements, attributes, etc., I serialize the objects to a .xml
file using XmlSerializer.

If I simply specify the "element.Value" property to the string data (what
should go inside the CDATA), the string simply becomes the inner text - it's
not wrapped in the CDATA delimiters. So it would appear that the classes
generated by XSD.EXE either can't or don't have enough information to
automatically wrap the data in a CDATA.

If I try to manually wrap the string data by specifying element.Value as
"<![CDATA[" + string + "]]>", the '<' and '>' characters get encoded as < and
respectively when I serialize the object to an XML file.

Is there a way to get the behavior I need - that is, the string data is
properly wrapped in the CDATA markers to create a valid element with CDATA
inner text?

Thanks,

Donnie
Aug 23 '06 #2

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

Similar topics

2
by: Rick | last post by:
Hi.. I've got some code I wrote in PHP that will generate a new argument string for the browser, but the xhtml parser in Firefox and Opera both complain about my use of &var=value pairs. Below...
0
by: Erwan | last post by:
Hi I have the following DTD (extract) <!ELEMENT d_field (table_ref?, item*, lst_caption?, frm_caption?, frm_layout?, frm_alert_onvalid?, input?, list?)> <!ELEMENT input (onvalid?)> <!ATTLIST...
2
by: X. Lee | last post by:
I am creating an xml schema, and I want one of the elements to include html text. Therefore, I want to make that element a CDATA elements so that it can accept html tags as part of it's value. ...
11
by: Dom | last post by:
Hi, I wanted to use the Button Element to submit a form like this example: <form action="/test.exe" method="post"> <button id="ID_BUTTON_OK" name="_WEB_EVENT_HANDLER_" type="submit"...
1
by: unwiseone | last post by:
Hello, Does any know how to specify a value of a DTD element? For example, here's an external DTD that I have: ======================================= <!ELEMENT summercamps (Camp+)>...
1
by: Ldaled | last post by:
Okay, I had a previous post called reading an XML document. Since this post I have revised my code and got it to work. Now, Like Derek had mentioned in answer to my previous post, I am getting an...
2
by: DesperateDan | last post by:
As the title say, I can't aquire element's value if it hosts sub-elements. Let me explain - My XML looks like this:- <a> <infill>xxxxxx</infill> <SourceEndPoint>testdata <EndPoint> <AliasRef...
4
by: Stefan Gentzmer | last post by:
Hello, how can i detect, if the text for a XmlElement has to be written as CDATA (i am using the XmlWriter) instead of a normal string. For example <start> <node1>HelloWorld</node1>...
15
by: Kapil Jain | last post by:
Dear All, What i need to achieve is : I am generating dynamic text boxes thru dhtml coding, i need onChange event of oragnistation text box i.e dynamically generated on click of "More" button in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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
0
BarryA
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...
0
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...
0
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...
0
jinu1996
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.