XmlWriter.WriteString() problem.

According to the Microsoft documentation, the .NET class 
System.Xml.XmlWriter.WriteString() does the following:

"Character values in the range 0x-0x1F (excluding white space characters 
0x9, 0xA, and 0xD) are replaced with numeric character entities (� 
through &#0x1F)."

However, when we call WriteString() in an application we have written, we 
are seeing the following exception being thrown:

System.ArgumentException: '', hexadecimal value 0x12, is an invalid 
character.
   at System.Xml.XmlUtf8RawTextWriter.InvalidXmlChar(Int32 ch, Byte* 
pDst, Boolean entitize)
   at System.Xml.XmlUtf8RawTextWriter.WriteElementTextBlock(Char* pSrc, 
Char* pSrcEnd)
   at System.Xml.XmlUtf8RawTextWriter.WriteString(String text)
   at System.Xml.XmlUtf8RawTextWriterIndent.WriteString(String text)
   at System.Xml.XmlWellFormedWriter.WriteString(String text)

Anyone ever seen anything like this?  Any idea what I am doing wrong?

Tom Delany

0
9/4/2007 8:08:57 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
882 Views

Similar Articles

[PageSpeed] 57

Tom Delany wrote:
> According to the Microsoft documentation, the .NET class 
> System.Xml.XmlWriter.WriteString() does the following:
> 
> "Character values in the range 0x-0x1F (excluding white space characters 
> 0x9, 0xA, and 0xD) are replaced with numeric character entities (� 
> through &#0x1F)."
> 
> However, when we call WriteString() in an application we have written, we 
> are seeing the following exception being thrown:
> 
> System.ArgumentException: '', hexadecimal value 0x12, is an invalid 
> character.
>    at System.Xml.XmlUtf8RawTextWriter.InvalidXmlChar(Int32 ch, Byte* 
> pDst, Boolean entitize)
>    at System.Xml.XmlUtf8RawTextWriter.WriteElementTextBlock(Char* pSrc, 
> Char* pSrcEnd)
>    at System.Xml.XmlUtf8RawTextWriter.WriteString(String text)
>    at System.Xml.XmlUtf8RawTextWriterIndent.WriteString(String text)
>    at System.Xml.XmlWellFormedWriter.WriteString(String text)
> 
> Anyone ever seen anything like this?  Any idea what I am doing wrong?

XmlTextWriter in the .NET framework 1.0/1.1 did that and XmlTextWriter 
in the .NET framework 2.0 still does that but the normal XmlWriter you 
create with e.g. XmlWriter.Create has been fixed to be compliant with 
the XML 1.0 specification and to ensure (by default) that the output is 
well-formed and even escaping those characters is not allowed in the XML 
1.0 specification.
So use new XmlTextWriter to create an XmlTextWriter or if you want to 
use XmlWriter.Create, then use XmlWriterSettings with CheckCharacters 
set to false e.g.

       XmlWriterSettings writerSettings = new XmlWriterSettings();
       writerSettings.CheckCharacters = false;
       using (XmlWriter xmlWriter = XmlWriter.Create("file.xml", 
writerSettings))
       {
         // ...
       }


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
9/5/2007 11:38:05 AM
Reply:

Similar Artilces:

small problem with save as
I'm using this to save my workbook as needed but it keeps asking me t save every time I touch the sheet..... Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) ActiveWorkbook.SaveAs FileName:=ActiveSheet.Range("g18") End Sub I need to edit this worksheet before I save it. PLease Help!!! Thanks, Vat -- Message posted from http://www.ExcelForum.com Open that workbook with macros disabled. Tools|macro|security (set it to the highest possible) Open your workbook Toss that macro out--It's pretty drastic Save your workbook reset the security level the way...

Debugging Problem In VBE
Hello, I have come across a strange phenomena as I'm stepping through my code with the F8 key in the VBA editor. There is a certain point in my subroutine where the rest of the code self-executes to completion. I'll explain more. When I reach the command (shown below) which happens to create a new document from a template, it executes fine. However, after this command executes, the VBA editor takes control of my debugging and executes the rest of my subroutine as though the entire macro had been executed at runtime. Obviously, this prevents me from stepping throug...

Report to pdf problem
Hello all! We are using Access2003/SQLServer2005 conbination with Stephen Lebans' ConvertReportToPDF and Tom Wickerath's SendMail functions. Everything was working well until about one month ago. When we would try to email a pdf from some computers, it would crash Access (i.e. the Microsoft alert would appear and the program would have to close). It started on the Server2003 machines and spread to the XP machines and some of the Vista PCs also. Here is what I have tried/checked: 1) Checked every computer's Access version and they are all the same. 2) Downloaded a...

Problems opening VNC links in IE
I've created a virtual map of my call centre with hyperlinks to each PC terminal (selecting local address and adding in the appropriate VNC link for each PC). This works fine in Visio, but when I try to export this as a web page to add to the local intranet it prevents the VNC links from opening. I have very limited Visio knowledge and can't figure out where I'm going wrong, so any help would be greatly appreciated... Well, since "This works fine in Visio", I'd start by verifying that the vnc software is installed on the web server you are attempting to execu...

RPC problems on server
Hello, We have moved our exchange server 2003 SP2 to a new hardware. Since then some clients are having problems to connect to the server. They get a timeout and a message, outlook is trying to connect to the server. When we try again it works most of the times. We already did a deep analyze with health check, but no problems here. We already run the exchange performance analyzer and we have noticed two problems Some latency's on disk and high RPC for the users. So when we look in the logon folder on the exchange we see for each mailbox approx 8 - 15 logons. We already ...

Problem with OAB
I have problems with my Offline address book It seems like my Outlook downloads an OAB from our organisations Exchange 5.5 period. How comes that Outlook downloads such old information? MN What does your Exchange administrator say? "Valleyriver" <please@nospam.com> wrote in message news:OYYl3xuxGHA.3452@TK2MSFTNGP04.phx.gbl... >I have problems with my Offline address book > > It seems like my Outlook downloads an OAB from our organisations Exchange > 5.5 period. > How comes that Outlook downloads such old information? > > MN > > There was a ...

Exchange Calendar Update Tool problems
I'm am having issues running the Calendar Update Tool and Calendar Items moving. 1) Server Patches are installed (DST) 2) Client Patches are installed (DST) 3) Exchange 2003 DST patch installed. 4) Trying to run Exchange Calenar update Tool on step 4 I am having issues. I used msextmzcfg.exe to generate the input and ini files and verified that the ini file is correct (points the the correct ExchangeDN, location of proper tzmove.exe file, outlook.exe location, registry location). I have a test input file with 2 users (including myself). I run the batch file that was created by msext...

Vista Windows Email Problem -Windows Security Popup
Hello, I can't get into my Vista Windows EMail because a Windows Security Login popup keeps asking to verify that my username and password are correct for the server. I've verified with Verizon that all of the server info is correct and that the problem is on my computer. The solutions I've seen are to delete this email account and start over. I'm willing to do that, however, I need to save some of the emails that are in this account. How do I do that before I delete the account? I can't forward any emails. Can I somehow save them to my hard drive and retriev...

macro problem #12
Finally with your last suggestion I�ve got it; Thanks indeed for your care on my problem!!! Cheers ;) ;) :) -- Gerbatin ------------------------------------------------------------------------ Gerbatin's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=15238 View this thread: http://www.excelforum.com/showthread.php?threadid=273207 ...

ip problems
Hi, We have MS CRM running on Windows 2003 box. The system is fully accessible from the server. However when we attempt to log on over the network, it runs for about 20 mins, then we get a page cannot be displayed error. We've set the server to a fixed ip address. Any ideas? Thanks in advance, Mike Hi Mike, Mine runs on a 2000 server package. I haven't had that error before but I looked on the IIS settings. The time- out on the CRM site is set to 10000 seconds (it's about 2hrs, 40mins). This is for an inactive user. Hope this helps jan >-----Original Message----- ...

Problems getting Sysvol to replicate on new Domain Controllers
When adding a new domain controller to the domain, the Sysvol will not replicate. This error has occurred on three Servers I promoted to test. Sysvol is replicating fine between the other 8 dc’s (4 in 1 site, each of the other 4 in their own site). I have done the following. Run dcdiag /v Issues that came up in the log are the failed advertising and sysvol tests (since no sysvol, this is to be expected). Under the FSMOCheck I noticed the PDC emulater is not the primary time server…..may not be anything since the tests passed. tarting test: FsmoCheck GC Name: \...

Advanced Filter Problem with Unique List
Ok, I've used Advanced Filter to created a unique list of City names. When the list is produced, the first city is always listed twice. The rest of the cities are unique. Has anyone ever experience this problem? I'm using Excel 2003. Please help !!!! Hi this normally happens when the column does not have a "heading" field, ie City. If you add a heading field into your data does it now work? -- Cheers JulieD check out www.hcts.net.au/tipsandtricks.htm ....well i'm working on it anyway "Faulk" <shane.faulkner@gmail.com> wrote in message news:111...

generating an XmlDocument from an XmlWriter
hi, I would like to make an XmlWriter write directly into an XmlDocument rather than writing it to a stream and then having to load it into a document. in the documentation for XmlWriter it rather tantalizingly says: "... For example, if you are using the XmlWriter to populate an XmlDocument ...." (just google for that phrase to see it in context) which implies that it it possible to do what I want, but I can't see any way of doing that. Andy Andy Fish wrote: > hi, > > I would like to make an XmlWriter write directly into an XmlDocument rather > than writ...

COleSafeArray problem with regional settings
We use COleSafeArray to send data to an excel spreadsheet, for one of our products (using Visual C++ 5.0, Excel97, Excel2000). The data includes data of various types (date, time, number), so the safe array has been set up as VT_VARIANT. A problem has occured with the use of this product in Germany, the numbers are not displayed correctly. They have Windows Regional Setting (WRS) as "German", which has:- a. Date seperator as '.' b. decimal seperator as ',' (decimal comma instead of decimal point). The numbers come out wrongly, as they seem to be interpreted as &...

Excel Problem #11
It's for a Nested Function. Enter this function in cell B1 and then use the fill in handle to copy the function down through cell B7. Enter the following data in the cells in the range A1:A7 and then write down the results in cells B1 through B7 for each set. Set 1: A1=IL; A2=IN; A3=IN; A4=OH; A5=IN; A6=OH; A7=IN Set 2: A1=WI; A2=KY; A3=IN; A4=IL; A5=IN; A6=IN; A7=OH not sure how nested functions work, if someone could tell me how to do this one i should be ok to figure it out from here. thanks -- Angell ------------------------------------------------------------------------ Angel...

OnMouseMove problem
Hi, I have a view which the user put controls on it (as many as he wishes to), I wanna change the icon whenever it is on the frame of the controls. The problem is that the View:OnMouseMove does not catch the Mouse Move on the other controls (e.g. CButton). I dont wanna rewrite the CButton::OnMOuseMove, cause I'll have to rewrite all my other controls, so I need a solution that will let me listen on the MouseMove for the view and all its sub controls. 10x, Janiv Ratson. You can capture the mouse to get mousemove messages. That will however not send the message to the button or other wind...

Apostrophe problem
Hello, I am working with a spreadhseet and the data looks normal, however when you click on the cell the data value contains a leading apostrophe. for example the data looks like this: '4 '8 '10 '8 IS there a quick and easy way to get rid of the leading " ' "? If so, an advice on how to do this would be greatly appreciated! Copy an empty cell, select the values and do edit>paste special and select add -- Regards, Peo Sjoblom "bcap" <rayh@patriots.com> wrote in message news:1185201567.622591.247730@k79g2000hse.googlegroups.com....

Big problem with VPN
Hello. I'm having a ****in' big problem with a VPN. This is my scenario: I have a Windows Server 2003, with DNS,DHCP,AD and ISA Server running. This server has 3 network cards: Internal Network: 192.168.0.1 / 255.255.255.0 (DNS/DHCP) Internet: 192.168.254.254 / 255.255.255.0 / 192.168.254.1 (This card is connected to a SpeedStream 5200 (router mode, not bridge)). Dedicated Link: 189.80.x.x / 255.255.255.252 / 189.80.x.x Here goes the problem: I made a VPN using ISA Server. The VPN connected sucessfully, but i wasn't able to see any server file, also i co...

Formatting Problem
I've created a blank booklet of x no. of pages with page size of h7.25" x w4.75" with 0.5" margins all around. I've been provided with material on floppies to incorporate into the booklet. The material is in the wrong font type and size and needs considerable change in other formatting. This I've done by opening the document into a WORD document of the same dimensions as stated above and tailoring the content to this WORD document. There are some centering, indents, right or left alignment. When I then try to insert this into the booklet in Publisher, s...

Are others having problems accessing this newsgroup?
Hi, For a couple days now, when I receive a notice in my Hotmail mail about a reply to a post I made here, I click on the "Read and rate the response" link and I get: "Sorry, the page you requested is not available. The page you were looking for is currently not available. The address may not be correct, or there may be a temporary problem with this site. Please try one of the following options: Check the address for typing errors. Click the Back button and try a different option from the navigation menu. Try this page again later. For additional assistance, try one of the...

Severe problems with Money Plus Deluxe
I was succesfully running the Money Plus Deluxe Win32 (on a Windows Vista OS) and suddenly I'm unable to run it again. When I try to do so, it appears a message telling me that program fails to start. I uninstalled the product and reinstalled it later, but the problem repeats again and again. I would appreciate any kind of help. In microsoft.public.money, Uriel wrote: >I was succesfully running the Money Plus Deluxe Win32 (on a Windows Vista OS) >and suddenly I'm unable to run it again. When I try to do so, it appears a >message telling me that program fails to start. ...

Excel Problems #7
I have recently converted from Windows 98 to Windows XP. My files partially migrated. I have tried reinstalling MS Office but Excel and Word are only partially installed. I have tried copying documents but XP can not open them. I have tried everything I can think of. Please help. What am I doing wrong? -- Thanks Tammy Try Opening WORD or EXCEL and then importing the documents. On My XP machine if I try doing something - and I get the error message like, "that option is not installed" and "would you like to install it" I just select "YES" and it installs tha...

Problems with Inserting Rows
Morning Everyone In my previous version of Excel I could click on a row and then "Insert copied cells" anywhere on the sheet (as a new row). My problem is that with this version (2003 professional), when I try and re-insert the row, all the formulas have been converted to values. How do I switch back to inserting the row with formulas Many thanks in advanc Ja Inserting a row seems to work the same in Excel 2003 as in earlier versions, but maybe if you lay out the _precise_ steps to duplicate the problem someone can help you. In particular "re-insert the row" is unc...

Problem with Update Trigger
SQL2008 I have two databases, both with identical tables ( apart from TableNames ). I have tried putting an update trigger on DB1.tbCBMOAccount to update the field country on DB2.tbBOSS_OAccount with the updated value from DB1.tbCBMOAccount ALTER TRIGGER [dbo].[trig_UpdateOriginatongAccounts] ON [DB1].[dbo].[tbCBMOAccount] AFTER UPDATE AS BEGIN Declare @OAccountID UniqueIdentifier Declare @Country varchar(32) Select @OAccountID = OAccountID , @Country = Country From Inserted IF UPDATE(Country) BEGIN UPDATE DB2.dbo.tbBOSS_OAccount SET Country = @Country ...

Excel 2003
These are the words of someone else on www.msfn.org with same problem as me (however, the answer give have not resolved the problem): I have a problem with Excel: When I select any cell, then let go of the left mouse button - it acts as though I am permanently holding down the left mouse button; i.e. it tries to select multiple cells. I cannot de-select the left mouse button and cannot access any of the menu buttons. The only thing I can do is right click on the taskbar at the bottom of the screen and close excel - open it up again and have the same problem! I also get a similar proble...