XmlSerializer question

Hi,

I use XmlSerializer to serialize xml string. It escapes xml special 
charaters, like < and > to < and >. How can I stop XmlSerializer to escape 
these charaters?

Thanks in advance!!!
Cindy
0
CindyLiu (5)
10/28/2004 6:05:03 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
830 Views

Similar Articles

[PageSpeed] 3

Cindy wrote:
> I use XmlSerializer to serialize xml string. It escapes xml special
> charaters, like < and > to < and >. How can I stop XmlSerializer to escape
> these charaters?

If the XmlSerializer didn't escape the characters < and & (and for 
compatibility >), then the result would not be well-formed XML. See section 
2.4 of the XML specification [1]. Here's a portion of the spec:

"The ampersand character (&) and the left angle bracket (<) MUST NOT appear 
in their literal form, except when used as markup delimiters, or within a 
comment, a processing instruction, or a CDATA section. If they are needed 
elsewhere, they MUST be escaped using either numeric character references or 
the strings "&amp;" and "&lt;" respectively. ..."

Is there a reason you don't want to generate well-formed XML, or are you 
trying to use the XmlSerializer to generate CDATA sections?

Cheers,
Stuart Celarier, Fern Creek

[1] http://www.w3.org/TR/2004/REC-xml-20040204/#syntax 


0
Stuart
11/1/2004 7:47:27 AM
Hi Stuart,

Because my data that is going to be serialized is also a well-formed xml. 
After the serialization, it is not xml string anymore. Is there anyway I can 
restore it to xml string in .Net? Do we have any class in .Net to perform the 
functions, like escape and unescape in javascript?

Thanks,
Cindy

"Stuart Celarier" wrote:

> Cindy wrote:
> > I use XmlSerializer to serialize xml string. It escapes xml special
> > charaters, like < and > to < and >. How can I stop XmlSerializer to escape
> > these charaters?
> 
> If the XmlSerializer didn't escape the characters < and & (and for 
> compatibility >), then the result would not be well-formed XML. See section 
> 2.4 of the XML specification [1]. Here's a portion of the spec:
> 
> "The ampersand character (&) and the left angle bracket (<) MUST NOT appear 
> in their literal form, except when used as markup delimiters, or within a 
> comment, a processing instruction, or a CDATA section. If they are needed 
> elsewhere, they MUST be escaped using either numeric character references or 
> the strings "&" and "<" respectively. ..."
> 
> Is there a reason you don't want to generate well-formed XML, or are you 
> trying to use the XmlSerializer to generate CDATA sections?
> 
> Cheers,
> Stuart Celarier, Fern Creek
> 
> [1] http://www.w3.org/TR/2004/REC-xml-20040204/#syntax 
> 
> 
> 
0
CindyLiu (5)
11/1/2004 5:54:02 PM
Seems like you are trying to serialise XML string as 'text'. There could be 
a couple of things that go wrong, I made a mistake myself once when setting 
an XML string as an InnerText instead of InnerXml.

Check the XML object 'before' serialisation, it probably has been encoded 
there not during serialisation.

-- 
Victor Hadianto
http://synop.com/Products/SauceReader/


"Cindy Liu" <CindyLiu@discussions.microsoft.com> wrote in message 
news:4A3E2D30-DC9F-403D-AF80-6DCFED129250@microsoft.com...
> Hi Stuart,
>
> Because my data that is going to be serialized is also a well-formed xml.
> After the serialization, it is not xml string anymore. Is there anyway I 
> can
> restore it to xml string in .Net? Do we have any class in .Net to perform 
> the
> functions, like escape and unescape in javascript?
>
> Thanks,
> Cindy
>
> "Stuart Celarier" wrote:
>
>> Cindy wrote:
>> > I use XmlSerializer to serialize xml string. It escapes xml special
>> > charaters, like < and > to < and >. How can I stop XmlSerializer to 
>> > escape
>> > these charaters?
>>
>> If the XmlSerializer didn't escape the characters < and & (and for
>> compatibility >), then the result would not be well-formed XML. See 
>> section
>> 2.4 of the XML specification [1]. Here's a portion of the spec:
>>
>> "The ampersand character (&) and the left angle bracket (<) MUST NOT 
>> appear
>> in their literal form, except when used as markup delimiters, or within a
>> comment, a processing instruction, or a CDATA section. If they are needed
>> elsewhere, they MUST be escaped using either numeric character references 
>> or
>> the strings "&" and "<" respectively. ..."
>>
>> Is there a reason you don't want to generate well-formed XML, or are you
>> trying to use the XmlSerializer to generate CDATA sections?
>>
>> Cheers,
>> Stuart Celarier, Fern Creek
>>
>> [1] http://www.w3.org/TR/2004/REC-xml-20040204/#syntax
>>
>>
>> 


0
victor8984 (11)
11/2/2004 6:59:23 AM
Reply:

Similar Artilces:

Formula Question? #2
Hello All, I am cuurently using this expression to count "Job" in an array. =COUNTIF(Database!K4:K15000,"Job") What I am looking for is a way to find this in a string of possible answers This answer may have "Job" ,but not the first in a line of possible answer ex: "Gui Job Run Exp" / "Run Exp Gui Job"/ etc... I've tried using "*" to find any "Job" in the array, but I thnk that the formula is looking at the first part of the answer only. Is there any other way of doing this without typing every possbile comb with &q...

Time Series Question
I have a line graph depicting product tests over a 2 week period. The Y axis are the results ranging from -10 to +10. The X axis is timescale. The problem I have is that the timescale only allows days, months and years. What I actually need is the x axis to breakdown into hours as multiple tests take place each hour. Is there any way that such can be accomplished in Excel? Regards Daz Use an XY chart, not what is confusing called a line chart. You can then set the X axis increment in Excel's time format. -- David Biddulph "news.microsoft.com" <Post2Group@Only....

CSplitterWnd questions
I would like to integrate a CSplitterWnd into my existing application. I have a window derived from CFormView containing two CListCtrl objects. I would like to place a CSplitterWnd horizontally between the two CListCtrl objects. All of the samples I can find for CSplitterWnd show the splitter being placed in a CMainFrame. Is there any way to place the CSplitterWnd in a CFormView? What would I have to change to get a CSplitterWnd between the two CListCtrl's on a CFormView? Thank you. CSplitterWnd wasn't designed for that. Take a look at these instead: http://www.codeproje...

Routing Question: 2 IMC's One Exchange Org
This is a multi-part message in MIME format. ------=_NextPart_000_0006_01C5AFAC.82F8B420 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Good morning all, I hope someone has a few minutes to enlighten me on = the finer detailes of Exchange 5.5 mail routing. I believe my questions = are rather basic, please share your knowledge if you have time! Scenerio: a.. Three Exchange 5.5 SP4 Mail servers in three physically different = location. b.. Location (A) has an IMC c.. Location (B) does NOT have an IMC d.. Location (C) has an IMC ...

XmlSerializer Collection with Collections
Hello I got this working but it is not how I really want it, basically I have an xml file which has a root of <test> and can be filled with 3 different types of <question> elements with different attributes, all share a base set of 4, one of the question types can have children with <option> elements, this is how the xml looks after serialization.... If you notice there is an extra <SelectionList> around the <option>'s in the final <question>, how can I write my class so I don't have this extra <SelectionList> element....my class follows, you ...

Answer to book questions
Hi, everything is a lot less than we actually make it. We are just filling in voids with senseless needs for answers. ...

Re: activation question
Hi Tian, Thanks for the reply, but nothing new in that information. I'm trying to make a custom control that has a drop down window. If I make this window a child of a dialog bar, it's clipped to the dialog bar. If I make it a child of the frame, I can draw on it, but I can't get focus and I can't force it to the top of the z order to get focus even if I call SetWindowPos with insert after the dialog bar or using the constant for top. Specifically how can I make a window that will not be clipped by the dialog bar it's placed in, and will recieve focus? Hi kermit,...

Port questions
Hi All, Just a few questions, wondering if anyone could answer them. 1. Can Exchange server traffic to limited to specific range of port? 2. Is there a recommended range of ports by Microsoft to lock Exchange into? 3. If #2 is no, then how many ports are needed by Exchange (1, 10, 50?). Pick a high range ports say from (62,520+) to lock Exchange into. On Thu, 6 May 2010 11:56:08 -0700, IDK215 <IDK215@discussions.microsoft.com> wrote: >Hi All, > >Just a few questions, wondering if anyone could answer them. > >1. Can Exchange se...

thread question #4
How can I determine in a block of code if the thread it's running in is the same as the main GUI thread? I was trying to use GetCurrentThread to get the thread the function is being called from. Not sure how compare that to GUI thread. On Wed, 21 Dec 2005 13:58:35 -0600, "Eric Margheim" <NOSPAM***eric@prism-grp.com***NOSPAM> wrote: >How can I determine in a block of code if the thread it's running in is the >same as the main GUI thread? > >I was trying to use GetCurrentThread to get the thread the function is being >called from. Not sure how...

Multiple Fields Query Question
Hi - I need to query multiple fields to find out how many times a specific horse was used for the purpose of a group or private lesson. My query is showing me "all" billing reasons as opposed to only the "lesson" ones. I've pasted the SQL below...is anyone able to help me with this? I just want to see the horses that were used for lessons only. I created this in Design View as I'm only familiar with creating queries that way, so if you could please be specific with any answers, I'd really appreciate it, since I do not know SQL. Thank...

A question of normalization
I've been developing an application for 2 years now that one may refer to as an inventory management database. I use the application on a daily basis to help run my business and it works nicely. I've recently begun to redesign the application and have decided that I come to a crossroads that is well beyond my expertise. I have 3 key tables: 1. tblItems: list of raw materials and other relevant information (12 fields in total) 2. tblSubAssemblies: list of sub assembly items and relevant info (9 fields in total) 3. tblFinishedProducts: list of finished products for resale and relevant i...

XmlSerializer
I'm having a basic problem with the XmlSerializer & i'm at my wits end trying to sort it out i have a basic clas <Serializable()> Class Tes Public Name as Strin End Clas when this serializes i wan <Test><Name>Value</Name></Test the problem is if i use the XmlSerializer clas Dim t as Tes t.Name="Value Dim sb As New StringBuilde Dim sw As New StringWriter(sb Dim Serializer As New XmlSerializer(Message.GetType Serializer.Serialize(sw, t Serializer = Nothin Console.Write(sb.ToStr...

Formula Question
I need to do some type of lookup and sum in vba I'd like to use Total Sheet.B5 to return the value Total Sheet.B5 to = 55 if Total Sheet.A5 = Orange Total Sheet A5 = Orange B5 = 55 Sheet 1 A4 = Blue b4 = 5 A5 = Green b5 = 10 A6 = Orange b6 = 15 Sheet 2 A4 = Orange b4 = 10 A5 = Green b5 = 20 A6 = Blue b6 = 30 Sheet 4 A4 = Green b4 = 20 A5 = Orange b5 = 30 A6 = Blue b6 = 40 Thank you for any help Hummm, I can't really tell what you're doing, but look here: http://www.xldynamic.co...

Stupid Question
Hey, This may sound stupid, but, how do you email a knowledge base article to a customer and record it in activities? --> Codeman --< There is no built-in way to do this. You need to copy and paste the KB article into a CRM E-mail. BTW, you can only copy KB article text when you view the article from Workplace in CRM. (If you view the KB article from the Service module's KB Manager, copy functionality is disabled for some reason.) -- Matt Wittemann http://icu-mscrm.blogspot.com "Codeman" wrote: > Hey, > This may sound stupid, but, how do you email a knowledge...

if/then question
Here's what I hope is a pretty basic question. I have 5 rows of inventory data. They are the following: A1: Product Name A2: Product Cost A3: Maximum Qty. Desired on Hand A4: Minimum Qty. Desired on Hand A5: Quantity on Hand Basically, it looks like this: Widget X | 25 | 10 | 4 | 5 I'd like to figure out how to write a formula for cell A6 that would tell me the following: If A5 is greater or equal to A4, then I'd like A6 = 0. If A5 is less than A4, then I'd like A6 = (A3-A5) * A2. Is this possible? Many thanks, Brendan Brendan this should work =IF(A5>...

STAN STARINSKI
I WANT A JOB IN YOUR GLOBAL EMPIRE. IS GOVERNOR STILL AVAILABLE? Kevin Panzke Jr. wrote: > I WANT A JOB IN YOUR GLOBAL EMPIRE. IS GOVERNOR STILL AVAILABLE? Yes...you get to govern his enormous head. If it tilts to the left, poor diet Coke in his ear. If it tilts to the right, poor Bud Light in his ear. When he babbles...shake his head figorously until he foams at the mouth. -- Vita brevis breviter in brevi finietur, Mors venit velociter quae neminem veretur. Death wrote: > Kevin Panzke Jr. wrote: > >> I WANT A JOB IN YOUR GLOBAL EMPIRE. IS GOVERNOR S...

XmlSerializer and shared objects (or How to generate IDREFs using XmlSerializer)
This is a multi-part message in MIME format. ------=_NextPart_000_007F_01C34AC1.11D4FB20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I am trying to find a solution that will allow me to use XmlSerializer = to serialize/deserialize a collection of objects where a given object is = shared between two or more other objects, and not create duplicate XML = representations of the shared object, but instead use IDREFs to refer to = the shared object. The XML I'm trying to produce is as follows (where "href" is an IDREF): <...

LoadLibrary question
Hi All, Could anyone please let me know if it is possible to load a library which has been built with a /MD compiler witch into an exe which has been build with a /ML compiler switch using 'LoadLibrary'? I am sure that it can be done, but I want to know what will be the implications of such a load? Would that be a good idea? Also, if at all I am to load a dll into an exe which has been statically linked to C runtime libraries (using /ML option), should the dll to be loaded be also statically linked to C runtime libraries or it will be OK if the dll has been dyanamically linked with C...

Mail Merge Question
Hello - When I do a mail merge from our excel database (excel 2002 SP3) to Word.. (word 2002 SP3)... to create labels, I have to specify which values I want to use because I don't want to use them all. For some reason... it's merging PAST the values I specify to fill up the last page. What gives? FNORD For help on Word mail merge using Excel as the data source. http://www.mvps.org/dmcritchie/excel/mailmerg.htm http://www.mvps.org/word/FAQs/MailMerge/CreateAMailMerge.htm http://www.mvps.org/word/FAQs/MailMerge/CreateADataSource.htm Gord Dibben Excel MVP On Mon, 7 Feb 2005...

POP3 / SMTP Using Exchange Question
I have a need to have a connection to Exchange as well as multiple POP3 accounts. Currently my default account is one of the POP3 accounts. I am having problems replying to emails that come into one of the POP3 accounts. I don't know what the problem is. Is there a way that I should be doing this? Here are the details. Say my POP3 account is mike@robbie.com. My Exchange (Active Directory) email address is mike@bobby.com. I have two accounts configured in Outlook, 1 Exchange and 1 POP3. I know my settings are correct since individually everything works fine. If I set my default acc...

questions about CToolbarCtrl buttons
Hi, I have a couple questions about buttons in CToolbarCtrl. Here is the code (It is from the KBBar example): NUM_TOOLBAR_BUTTONS = 4; COMBO_IDX = 3; if (!CToolBarCtrl::Create(DEFAULT_TOOLBAR_STYLE, rcClientParent, pWndParent, IDR_IETOOLBAR)) return false; SetButtonSize(CSize(24, 24)); AddStrings("Go\0Stop\0Options\0"); if (AddBitmap(3, IDR_IETOOLBAR) == -1) { DWORD dwError = ::GetLastError(); return false; } TBBUTTON tbs[NUM_TOOLBAR_BUTTONS]; for (int i = 0; i < NUM_TOOLBAR_BUTTONS; i++) { tbs[i].dwData = 0; tbs[i].fsState = TBSTATE_ENABLED; tbs[i].f...

Date Question
In Money 2006, In previous versions of Money you could set the check register to show either the date an EPay was processed by the back or the date it was due at the Vendor. In Money 2006 I can't seem to find that setting. Can anyone direct me to the right place? Thanks. Steve ...

Pivot Table Questions (Excel 2003)
I have a workbook with several PivotTables all on a separate sheet, but pulling data from one table. At first everything was working fine and I was able to create, modify, and refresh my PivotTables as needed. But something changed. Several of my older PivotTables would no longer refresh and would instead give me an error message. I could no longer modify some PivotTables and received an error stating that I had to many columns/rows. Meanwhile, the newer PivotTables seemed to be working fine. But now, everything is messed up. None of my PivotTables are working or refreshing. Has anyone ...

Excel 2007 Macro/VB Question DDE Question
Hi, So I have a column of cells that are the combination of a other cells in the row and a result of a few "if functions." The value comes out exactly as planned however in order for the data to be sent to the DDE server I need to press F2, go the beginning of the cell to insert an "=" sign and then press enter. I would like a macro to do what I just mentioned and then go down to the cell in the column. I used to write code using C++, but I'm a little rusty and unfamiliar with VB. Below is the formula and then the result of the cell. Any informat...

Form/Procedure question
I am new to access and am trying to create a simple application that will allow a user to type in two store numbers and then I will search the database for the stores and return some correlation values. (I have a script written in sql to find the correlation) but am going to have to convert it to access. Can this be done, any suggestions on where to start. Do I create a form and then somehow link the procedure to it? Can this even be done and is this the best way to do it? THANKS!!! You may not need a procedure to do it, depending on what it is you're actually doing it could be ma...