How to XmlSerialize directly into XmlDocument

Hi

this approach works IF the target document is empty:

XmlDocument doc = new XmlDocument();
XPathNavigator nav = doc.CreateNavigator();
XmlSerializer ser = new XmlSerializer(typeof(string));
using (XmlWriter writer = nav.AppendChild()) {
    ser.Serialize(writer, "works ok");
}//using

but if I want to insert the xml into an existing element:

XmlDocument doc = new XmlDocument();
doc.AppendChild(doc.CreateElement("Root"));
XPathNavigator nav = doc.FirstChild.CreateNavigator();
XmlSerializer ser = new XmlSerializer(typeof(string));
using (XmlWriter writer = nav.AppendChild()) {
    ser.Serialize(writer, "fails");
}//using

giving message "WriteStartDocument cannot be called on writers created
with ConformanceLevel.Fragment."

Does anybody know of a workaround?
0
first101 (1)
9/27/2010 4:44:31 PM
dotnet.xml 7266 articles. 0 followers. Follow

0 Replies
1937 Views

Similar Articles

[PageSpeed] 52

Reply:

Similar Artilces:

OWA http re-direct
Hello All: Does anyone know why http://mail.mydomain.com/exchange does not re-direct to https://mail.mydomain.com/exchange ? Instead it gives me a 403 error forbidden. Please help! Best, Rick "Rick" <Rick@discussions.microsoft.com> wrote: >Does anyone know why http://mail.mydomain.com/exchange does not re-direct to >https://mail.mydomain.com/exchange ? Why would you expect it to do that? Those are two different port numbers but the same virtual directory. >Instead it gives me a 403 error forbidden. When you use the /Exchange virtual directory you're real...

Assigning a cell from a sheet directly to a cell of another sheet
Just a sample nomenclature Thank's ahead A sheet cell to another sheet cell of the same Workbook. Thank's I got my answer. ...

How do I make a 3 d graph using depth in Ft., a N-S direction in .
I am trying to make an oilwell borehole 3 d graph. The data I have available is the depth in feet, the direction in a North/South Direction and from an East/West direction, both in feet, from a GPS references starting point. I would like to track this well bore and compare it to several others in the same proximity, possibly putting a flag if they come within a certain specified distance from each other. I have data for each well in similar column layouts, on separate excel sheets. Would like one compilation graph of however many wells (probably 4 would be the most) I chose to offse...

Exchange Direct Push #2
I have one user with a Samsung Blackjack phone with Windows Mobile 5.0... I'm trying to setup Direct Push to him but can't get it to sync. I have one Exchange 2003 (sp2) server on Windows 2003 Server (sp1). We are running OWA with Forms-based auth. It is behind a Checkpoint firewall. When I try to sync with SSL (on the phone) turned on, I get the error 0x8503002 (server is not an Exchange server). When I try to sync without SSL turned on, I get the error 0x85010004 (account does not have permission). All settings for user is correct. I've done the (http://www.petri....

direct deposit into muliple accounts
I have my direct deposit separated into multiple accounts. How can I reflect that in Money? First an assumption: the accounts in question are all in Money. Put Transfer:[name of other Money acct] transactions on the After Tax tab. Say your net income is $1,500 and you split it into $1,350 to "Checking" and $50 to "Savings" and $100 to your "Vacation Home Savings" account. Put a paycheck transaction with a total amount of $1,350 in your "Checking" account. On its after tax tab, add two lines: $50 Transfer:Savings $100 Transfer:Vacation Home Savin...

XmlDocument save and end tag formatting
Hi, I am doing some work with the XmlDocument class for loading and saving files and I notice that the save call is writing out the empty element in the following format <element /> - is this formatting possible to control? ie. get it to write out <element></element>. Thanks Donal "Donal McWeeney" <donal_mcweeney@NO-SP-AM.aimware.com> wrote in message news:O0TtH$ctDHA.2004@TK2MSFTNGP10.phx.gbl... > Hi, > and I notice that the save call is writing out the empty element in the > following format <element /> - is this formatting possible...

Using XMLDocument to load chinese characters
Hi, I am getting an error while loading a file having Chinese characters. I am using XMLDocument to parse the XML. Please let me know if you have any idea about the same Thanks Hitesh wrote: > I am getting an error while loading a file having Chinese characters. I > am using XMLDocument to parse the XML. What error message do you get exactly? If the encoding of the XML file is not properly declared, for instance in the XML declaration, then the parser might find bytes it can't decode and that is an error. So make sure you use an encoding that allows Chinese characte...

Simple XSL Transformations using XmlDocument
Hi, I found the XSL Transformation through .NET too complex. The most simplest overload of System.Xml.Xsl.XslTransform is Transform(inputfile, outputfile), but this saves the result into file. I need to supply the XmlDocument object (with the source tree loaded) and receive the output in string. Traditionally I do this thing in very simple way which is as below: dom.load "xmldoc.xml" sdom.load "xsldoc.xsl" str = dom.transformNode(sdom) Could someone give the .NET equivalent for above code? Thanks in advance, Fahad Fahad Ashfaque wrote: > I need to supp...

How do I send a direct email?
Hi everyone I have a marketing list of 225 contacts selected from the main database, and I want to send them each a personalised direct email. I have a template set up for this, but can't figure out how to bring this together with the marketing list to launch the campaign. The instructions I have say that I should see 'Send direct email' in the actions menu, or see an icon on the action bar. I have neither. Help! As far as I remember, direct e-mail is only available in the web client and does not appear in the Outlook client. Also, I think it is only available in a contact ...

Reprint Direct Deposit Advices
We would like the ability to reprint the direct deposit advices after the payroll has been posted. ...

Re-download transactions via direct connect?
I have Money 2007 connect to my brokerage via Direct Connect, and (presumably) due to some file corruption, it missed a couple of months of transactions. I think (hope) the corruption is fixed due to file repair. However, I can't seem to find a way to get Money to download the missing period of transactions. Other than re-creating the file or account from scratch, is there a way that I can get Money to attempt to download transactions again for a prior period? Is it even possible for OFX imports? Thanks, John In microsoft.public.money, johndog wrote: > >I have Money 2...

Sending a report directly to a printer
How do I send a report (via a button) directly to a printer bypassing the print preview screen? I still want the general office printer selection dialog box to open up, so the users can select their local printer. Cheers, GLT. If you are using Access 2002 or later, you can set the Printer object before you OpenReport in acViewNormal. You probably want to create a little unbound form with a list box that you populate with the members of the Printers collection. You can even use a custom property on the report so that it remembers to use that printer again next time the report is opene...

Direct Input Link Error 1103 for DXGUID.LIB
I have been trying to use the latest Direct Input SDK files with VC 6 ( a joystick read program). I can compile an exe but can't compile Debug version because of a Link 1103 error for dxguid.ib, cant get debug info. Is there some simple way to get around this or is this a real incompatability (as was discussed in earlier thread) ? -- Thanks, Patches ...

HELP! Microsoft.Crm.Platform.Proxy is not intended for direct use, please use the public SDK.
Can someone post the following DLL's from CRM 1.2? They should be on the installation CD. If you want to e-mail send to robert[at] ockhamgroup.com Microsoft.Crm.Platform.Proxy.dll (1.2.3297.0) Microsoft.Crm.Platform.Types.dll (1.2.3297.0) Details... I'm attempting the following solution: Moving External Data into Microsoft CRM: Lead Generation http://msdn2.microsoft.com/en-us/library/ms913871.aspx http://download.microsoft.com/download/e/4/5/e45c4994-6878-4871- 8699-6793b8f13c34/leadgeneration.exe What I need is either: 1. a working compiled LeadGenerator.exe executable; o...

Backing Up Directly Across the Network
Hi All ~ One problem I'm having and I haven't been about to get resolved concerns the daily backups. I've tried to backup directly to the other system's shared drive (non-database) and I can't get that to work. I've created a shared drive on the second register - on the non-database system - but when I try to backup directly to the shared drive the operation fails. I always need to make a copy on the database server, which isn't really a backup since it's on the same server, same hard drive, as the POS database. Once the backup is done, I then use the copy ...

Direct Mail button missing
If you use the web client when looking at a list of acounts you have the option to send direct mail. If you open the outlook client this option is not available. OK...you have mail merge instead! (well I would still like direct mail but....) If you go back to your outlook client the direct mail button has gone! Now that's just not nice. Does anyone know if this is 'by design' and if there is a fix for it? Thanks Andy Andy, the send email button is located on each individual contact form. HTH Frederic www.traviata.be Hi Frederica I understand that the email button ...

Opening XLS files directly
OK I apologize for the bad subject line but this is a strange problem. Guru's, I am at your mercy! Let me lay out some basic stuff. PC running Windows 2000 Pro Office 2000 with latest patches and updates installed 1.8 Ghz, 512 mb memory, over 80 gig's on hard drives available. When the user double-clicks on an Excel icon, Excel starts but before the sheet can be displayed an error box shows up. It states, "Cannot find the file "[file requested]" (or on of its components). Make sure the path and filename are correct and that all required libraries are available."...

I need help insert a decimal other then directly to the right of t
I am importing a text file in to Excel. The data for the amount filed does not include the decimal place. So I need to insert the decimal into the number. For example the data is 1234 I want to insert the decimal right in the middle as 12.34 I would greatly appreciate anyones help on this. If you always want the last two digits to be after the decimal, then enter 100 in an empty cell, then copy it, select the cells you want to change and select Paste Special. Click divide and all of your selected cells will be divided by 100. Note that blank cells will now be 0. "Law"...

problems with automatic debit/direct debit
My Money is not allowing me to use automatic debit like I was used to using with my other bank. Is this a bank problem or do I not have something configured right? Michael Before someone can give a useful answer, you'll probably need to elaborate a bit on what you mean by "is not allow me to use automatic debit". -- Chris Cowles Gainesville, FL "mpmorin" <mpmorin@verizon.net> wrote in message news:4Apde.13057$KP.2990@trndny02... > My Money is not allowing me to use automatic debit like I was used to > using with my other bank. Is this a bank p...

What formats can I insert directly into publisher (i.e. PDF)
I know I cannot insert PDFS and have been changing them to JPEGs but this reduces the quality is there a better format I should be changing them to ? Thanks Wendy Might try this If you are asking about print publication: Converting PDF Files So that they can be imported into Publisher http://ed.mvps.org/Static.aspx?=Publisher/convertpdf -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Wendy" <Wendy@discussions.microsoft.com> wrote in message news:D5DB0409-75F9-4529-BF05-4D748B554A35@microsoft.com... >I know I ca...

Direction of selection in CRichEditCtrl
I believe that CRichEditCtrl::GetSel() does not relay a key piece of information regarding the current selection, namely the direction of the selection. This function always returns the smaller position first, and the larger position second. I would expect this function to return the larger position first and the smaller position second in the case of the user selecting backwards (from right to left). The reason for my expectations is that CRichEditCtrl::SetSel() does support this scheme for relaying the direction of the selection, unlike CRichEditCtrl::GetSel(). I can put the cursor at the e...

XmlSerializer constructor fails with xsd.exe generated class
I'm new to .net so here goes. I'm tying to deserialize a class that is associated with an XML schema. I created the C# class with xsd.exe as below: xsd.exe /c /n:somenamespace properties.xsd this creates properties.cs When I do XmlSerializer s = new XmlSerializer(typeof(somenamespace.properties)); I get the standard exception everyone gets when the DOM compiler fails ("File or assembly name _utcyjot.0.dll, or one of its dependencies, was not found") (I copied the dll name from below) Using Chris Sells' XmlSerializerPreCompiler tools gives me the following e...

Open forum in add mode directly from desktop
Could somebody please tell me how to Open forum in add mode directly from desktop for the desktop or tell me where I can go for an answer THanks in advance!! ...

Gp 9.0 direct Deposit
Can you import direct deposit accounts using integration manager? My company currenty uses a webach service and we are switching to Driect Deopsit in GP 9.0 The issue I have is we have almost 500 employees with direct deposit. I can pull a csv file from the online service with all of their account info in it. I have setup integrations before however I can't seem to be able to find the table that contains the direct deposit info. --Jason Botkin Jason, look at table DD00200 (Direct Deposit Employee Account Master). rc "jasonb" wrote: > Can you import direct deposit ac...

Text not fully displayed when text direction changed
I've got a worksheet where most of the text is displayed as usual, reading left to right. I've changed some cells so text direction is -90. When I type into these cells the first part of the first word is partly hidden. It's a bit irritating since the text displays normally in "print preview" and prints correctly - it just doesn't display correctly on the screen. Any help would be gratefully appreciated A shot in the dark: Remove any formatting (left, center or right justified) by un-selecting their respective buttons. Gilles "Mikey9131" <mikewoo...