473,769 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deserialization With XML Elements That Contain HTML

Hello,
I was wondering if there is a way to have the contents of an XML element
that contains HTML to be deserialized into the cooresponding string property
without the HTML tags being surronded by CDATA?

<?xml version="1.0" encoding="UTF-8" ?>
<introduction >
<header>
<h1>Helping you achieve the natural look you want</h1>
</header>
<text>
<pThe comprehensive resource connecting you with reliable
infor..</p>
</text>
</introduction>

Deserialize into:

[System.Xml.Seri alization.XmlRo otAttribute(Ele mentName=Consta nt.Introduction Element, Namespace = "", IsNullable = false) ]
public class Introduction
{
//Private variables.
private string _header = string.Empty;
private string _text = string.Empty;

[System.Xml.Seri alization.XmlEl ementAttribute( Constant.Header Element)]
public string Header
{
get
{
return this._header;
}
set
{
this._header = value;
}
}

[System.Xml.Seri alization.XmlEl ementAttribute( Constant.TextEl ement)]
public string Text
{
get
{
return this._text;
}
set
{
this._text = value;
}
}

}

I want the properties of the above class when returned to contain the HTML
tags but I cannot use CDATA around those tags.

Any help will be very much appreciated.
Thanks,
Ken
Feb 14 '07 #1
3 5278

Can you add the InnerHTML property to your serialization attribute?

Kenneth H. Brannigan wrote:
Hello,
I was wondering if there is a way to have the contents of an XML element
that contains HTML to be deserialized into the cooresponding string property
without the HTML tags being surronded by CDATA?

<?xml version="1.0" encoding="UTF-8" ?>
<introduction >
<header>
<h1>Helping you achieve the natural look you want</h1>
</header>
<text>
<pThe comprehensive resource connecting you with reliable
infor..</p>
</text>
</introduction>

Deserialize into:

[System.Xml.Seri alization.XmlRo otAttribute(Ele mentName=Consta nt.Introduction Element, Namespace = "", IsNullable = false) ]
public class Introduction
{
//Private variables.
private string _header = string.Empty;
private string _text = string.Empty;

[System.Xml.Seri alization.XmlEl ementAttribute( Constant.Header Element)]
public string Header
{
get
{
return this._header;
}
set
{
this._header = value;
}
}

[System.Xml.Seri alization.XmlEl ementAttribute( Constant.TextEl ement)]
public string Text
{
get
{
return this._text;
}
set
{
this._text = value;
}
}

}

I want the properties of the above class when returned to contain the HTML
tags but I cannot use CDATA around those tags.

Any help will be very much appreciated.
Thanks,
Ken
Feb 14 '07 #2
The serialization attribute is a .NET provided attribute. I have not seen a
way of specifiying the InnerHTML or InnerXML property.

"John Bailo" wrote:
>
Can you add the InnerHTML property to your serialization attribute?

Kenneth H. Brannigan wrote:
Hello,
I was wondering if there is a way to have the contents of an XML element
that contains HTML to be deserialized into the cooresponding string property
without the HTML tags being surronded by CDATA?

<?xml version="1.0" encoding="UTF-8" ?>
<introduction >
<header>
<h1>Helping you achieve the natural look you want</h1>
</header>
<text>
<pThe comprehensive resource connecting you with reliable
infor..</p>
</text>
</introduction>

Deserialize into:

[System.Xml.Seri alization.XmlRo otAttribute(Ele mentName=Consta nt.Introduction Element, Namespace = "", IsNullable = false) ]
public class Introduction
{
//Private variables.
private string _header = string.Empty;
private string _text = string.Empty;

[System.Xml.Seri alization.XmlEl ementAttribute( Constant.Header Element)]
public string Header
{
get
{
return this._header;
}
set
{
this._header = value;
}
}

[System.Xml.Seri alization.XmlEl ementAttribute( Constant.TextEl ement)]
public string Text
{
get
{
return this._text;
}
set
{
this._text = value;
}
}

}

I want the properties of the above class when returned to contain the HTML
tags but I cannot use CDATA around those tags.

Any help will be very much appreciated.
Thanks,
Ken
Feb 14 '07 #3
Kenneth H. Brannigan wrote:
Hello,
I was wondering if there is a way to have the contents of an XML element
that contains HTML to be deserialized into the cooresponding string property
without the HTML tags being surronded by CDATA?

<?xml version="1.0" encoding="UTF-8" ?>
<introduction >
<header>
<h1>Helping you achieve the natural look you want</h1>
</header>
<text>
<pThe comprehensive resource connecting you with reliable
infor..</p>
</text>
</introduction>

Deserialize into:

[System.Xml.Seri alization.XmlRo otAttribute(Ele mentName=Consta nt.Introduction Element, Namespace = "", IsNullable = false) ]
public class Introduction
{
//Private variables.
private string _header = string.Empty;
private string _text = string.Empty;

[System.Xml.Seri alization.XmlEl ementAttribute( Constant.Header Element)]
public string Header
{
get
{
return this._header;
}
set
{
this._header = value;
}
}

[System.Xml.Seri alization.XmlEl ementAttribute( Constant.TextEl ement)]
public string Text
{
get
{
return this._text;
}
set
{
this._text = value;
}
}

}

I want the properties of the above class when returned to contain the HTML
tags but I cannot use CDATA around those tags.

I'd say you are going to have to do custom deserialization - implement
IXmlSerializabl e on Introduction and in the ReadXml method, just get the
InnerText (probably) of the element.
--
Larry Lard
la*******@googl email.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Feb 15 '07 #4

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

Similar topics

2
5240
by: Falc2199 | last post by:
i all, I have an HTML table within which I have a span. When the user clicks a button I want to update the contents of this span with form elements table elements (TR,TD). The problem is that if I do not wrap the span tag inside a TR and TD, it is not properly placed in the table and the update does not work at all. However if I do place the span inside a TR and TD, the TR and TD which was supposed to go into the span is not becoming...
3
9796
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I am having problems deserializing an object which seems to be serializing just fine. I save the byte array of the serialized object in the database (when I check the database the field that holds the binary data seems populated), but when I want to deserialize this same byte array the application fails and gives me the following error: Binary stream does not contain a valid BinaryHeader, 0...
3
2069
by: AnkitAsDeveloper [Ankit] | last post by:
Hi i am serializing a 'ref struct' object as follows : private: void Seri( String ^path, Object^ obj ) { FileStream^ fileStrm ; try { //Serialize entire object into Binary stream
2
1775
by: andreas | last post by:
Hi, if have a object arrSdList of type SortedList for serialization and deserialization there are two subs for doing this Public Sub deser Dim Formatter As BinaryFormatter = New BinaryFormatter() Dim ReadFile As FileStream ReadFile = File.OpenRead(FilePad)
3
9795
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the response. As a result of seraching news groups I guessed that the SOAP response defines an array element in a way that causes the dotnet deserialization routines to put the content in a generic object array (object) BUT the content is supposed to...
1
3751
by: parrot toes | last post by:
I tried to post this question before, but there was an error when posting. I case it did get posted and in order to avoid duplication, I'll just repost a summary. I have written a dotnet client that accesses a Axis provided web service. The client uses the code generated, using wsdl.exe, from the wsdl file provided by the web service provider. The web response has the following schema (roughly):
5
2294
by: Greg Allen | last post by:
I am consuming a web service and using the generated Reference.cs to access the service and the objects associated with it. I have run into a problem where some inherited classes are not being deserialized. I have verified that the XML being returned by the service contains the tags I am expecting, but they don't show up in the resulting object. Here's the relevant portion of the Reference.cs file: public class FormSection {
7
2179
by: Jason | last post by:
I have some XML that contains some null elements, for example: <Document> <StartDate/> <EndDate/> </Document> I would like to process the XML using the .NET serialization tools (XSD.exe). The schema for the XML is under external control (i.e. I can't change it).
6
2502
by: beachdog | last post by:
I am building a client which accesses a web service (HTTP/SOAP), and I think the response message is somehow not in agreement with my wsdl/ proxy class. I am able to access SOAP headers ok from the deserialized response, but not elements in the body of the response. Is there some way I can get some sort of debug tracing out of the deserialization layer, or step thru it in debugger somehow, so I can see how it is parsing the message and...
0
9590
marktang
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...
0
9424
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
10223
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
10051
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 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...
0
8879
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...
0
6675
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
5310
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...
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.