473,621 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Va lue" 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 4026
(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.Va lue" 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
2109
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 is my code that generates the string : function InvokeURL(url_to_forward_to) { try {
0
1150
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 input default_value CDATA #IMPLIED modify (normal | disable | restrict) "normal"
2
14326
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. I'm having trouble doing this though. Can anyone give me a sample of how to do that? so if this is my xml instance: <root> <element><!CDATA]></element>
11
3092
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" value="ID_BUTTON_OK">Login</button> </form>
1
1285
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+)> <!ELEMENT Camp (name, campcode?, ContactPhone, ContactPhone?, Activity+)>
1
3646
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 XmlException. The error message is invalid date SEMICOLON expected at Line 1 Position 380. Derek you had said something about the UTF encoding attribute in the xml declaration, it is in fact UTF-8. So if this is my problem or what is causing the...
2
1106
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 ref="lAlias120001"> <Qualifier><!]></Qualifier>
4
2331
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> <node2>a>b</node2>
15
2311
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 myhtml page in series manner like oragnisation0,oragnisation1,oragnisation2 and so on, and popup window will open onChange event of (oraganisation<iCount>) with one query string / parameter i.e value of oraganisation so that i will use that...
0
8156
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,...
0
8653
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8457
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7127
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6101
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5554
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();...
0
4065
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...
1
1763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1460
bsmnconsultancy
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...

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.