473,325 Members | 2,774 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,325 software developers and data experts.

CDATA for XmlTextAttribute

After serialzing I want,

<MyRequest>
<Content
SigningScheme="pkcs7"><![CDATA[JFHSKDKFJ869KJ7hk96HKKghgfk46294857J]]></Content>
</MyRequest>

__________________________________________________ _______________________________________

My class looks like,

public class Content
{
private string _signingScheme;
private string _payLoad;

[XmlAttribute("SigningScheme")]
public string SigningScheme
{
get { return _signingScheme; }
set { _signingScheme = value; }
}

[XmlText]
public string PayLoad // stuff that needs to be in <!CDATA.. >
{
get { return _payLoad; }
set { _payLoad = value; }
}
}

Sep 1 '06 #1
4 9047
* kplkumar wrote in microsoft.public.dotnet.xml:
>After serialzing I want,

<MyRequest>
<Content
SigningScheme="pkcs7"><![CDATA[JFHSKDKFJ869KJ7hk96HKKghgfk46294857J]]></Content>
</MyRequest>
Why?
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Sep 1 '06 #2
"kplkumar" <kp******@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
After serialzing I want,

<MyRequest>
<Content
SigningScheme="pkcs7"><![CDATA[JFHSKDKFJ869KJ7hk96HKKghgfk46294857J]]></Content>
</MyRequest>

__________________________________________________ _______________________________________

My class looks like,

public class Content
{
private string _signingScheme;
private string _payLoad;

[XmlAttribute("SigningScheme")]
public string SigningScheme
{
get { return _signingScheme; }
set { _signingScheme = value; }
}

[XmlText]
public string PayLoad // stuff that needs to be in <!CDATA.. >
{
get { return _payLoad; }
set { _payLoad = value; }
}
}

Out of curiosity, why does it need to be in CDATA. The example you gave
contains no special characters.

John
Sep 1 '06 #3
kplkumar wrote:
After serialzing I want,

<MyRequest>
<Content
SigningScheme="pkcs7"><![CDATA[JFHSKDKFJ869KJ7hk96HKKghgfk46294857J]]></Content>
</MyRequest>
You don't need CDATA markup unless the text content contains markup
characters (< or &). Using it for any other reason is evidence that
the document type has been designed incorrectly.

See http://xml.silmaril.ie/authors/cdata/

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Sep 2 '06 #4
Alrite....... the question is not why I want to do it. It' about how to
do it. I have acheived it, by using a class called CDATA which is
implements IXmlSerializable. It works like charm.

Then I added in my class property,

some xml serializable class,
{
.......

[XmlElement("PayLoad", Type=typeof(CDATA))]
public CDATA PayLoad
{
get { return _payLoad; }
set { _payLoad = value; }
}
}
public class CDATA : IXmlSerializable
{
private string text;
public CDATA()
{}

public CDATA(string text)
{
this.text = text;
}

public string Text
{
get { return text; }
}

/// <summary>
/// Interface implementation not used here.
/// </summary>
XmlSchema IXmlSerializable.GetSchema()
{
return null;
}

/// <summary>
/// Interface implementation, which reads the content of the CDATA
tag
/// </summary>
void IXmlSerializable.ReadXml(XmlReader reader)
{
this.text = reader.ReadElementString();
}

/// <summary>
/// Interface implementation, which writes the CDATA tag to the xml
/// </summary>
void IXmlSerializable.WriteXml(XmlWriter writer)
{
writer.WriteCData(this.text);
}
}

Sep 19 '06 #5

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

Similar topics

3
by: Balaras | last post by:
Hi, Can sombody here please help me a bit with a regular expression. I have a xml file where I need to strip the CDATA sections of any contained data. Eg. <xml> <tag><]></tag>...
6
by: Cade Perkins | last post by:
How can the CDATA ending delimiter "]]>" be represented within a CDATA section itself? Consider an XML document that is intended to contain an embedded, uninterpreted XML example. Generally,...
1
by: Tom Regan | last post by:
Is it possible to mark a base class member with XmlTextAttribute and serialize a derived class? When I attempt to do so I get this error: There was an error reflecting type ''. --->...
10
by: Jon Noring | last post by:
Out of curiosity, may a CDATA section appear within an attribute value with datatype CDATA? And if so, how about other attribute value datatypes which accept the XML markup characters? To me,...
11
by: ericms | last post by:
Can anybody show me how to insert a CDATA section using XPathNavigator ? I have tried the follwing with no luck: XmlDocument docNav = new XmlDocument(); docNav.LoadXml(xmlString);...
1
by: soccerdad | last post by:
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...
12
by: Peter Michaux | last post by:
Hi, I am experimenting with some of the Ruby on Rails JavaScript generators and see something I haven't before. Maybe it is worthwhile? In the page below the script is enclosed in //<!]> ...
7
by: Max | last post by:
Hello everyone! Can anyone help me to convert the CDATA expression "CDATA ::= (Char* - (Char* ']]>' Char*)" to Javascript Regular Expression? Thanks, Max
6
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
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 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.