Creating XML Text

Hello,

I need to create some well formed XML text live in memory. What I really 
want is to use the XmlTextWriter object applied to some location in memory 
(Stream or something?), because it does a nice job of formatting/identing, 
etc. But I can't figure out how to instantiate the XmlTextWriter object 
correctly w/o a filespec. I'm not allowed to directly instantiate a Stream & 
therefore a StreamWriter for that matter since there's no filespec involved. 
Can someone show me some code to make this work?

TIA,

-- 
John C. Bowman
Software Engineer
Thermo Electron Scientific Instruments Div.
<Remove this before reply> john.bowman@thermo.com 


0
10/22/2004 7:19:50 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
768 Views

Similar Articles

[PageSpeed] 37


John Bowman < wrote:


> I need to create some well formed XML text live in memory. What I really 
> want is to use the XmlTextWriter object applied to some location in memory 
> (Stream or something?), because it does a nice job of formatting/identing, 
> etc. But I can't figure out how to instantiate the XmlTextWriter object 
> correctly w/o a filespec. I'm not allowed to directly instantiate a Stream & 
> therefore a StreamWriter for that matter since there's no filespec involved. 
> Can someone show me some code to make this work?

You could use a StringWriter as a TextWriter to create the XmlTextWriter on:

     StringWriter stringWriter = new StringWriter();
     XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
     xmlWriter.WriteStartElement("gods");
     xmlWriter.WriteStartElement("god");
     xmlWriter.WriteAttributeString("name", "Kibo");
     xmlWriter.WriteEndElement();
     xmlWriter.WriteEndElement();
     xmlWriter.Flush();
     xmlWriter.Close();
     Console.WriteLine(stringWriter.ToString());


-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
10/23/2004 11:08:22 AM
Martin,

Thanks! That works great.

John

"Martin Honnen" <mahotrash@yahoo.de> wrote in message 
news:euLFeCPuEHA.2072@tk2msftngp13.phx.gbl...
>
>
> John Bowman < wrote:
>
>
>> I need to create some well formed XML text live in memory. What I really 
>> want is to use the XmlTextWriter object applied to some location in 
>> memory (Stream or something?), because it does a nice job of 
>> formatting/identing, etc. But I can't figure out how to instantiate the 
>> XmlTextWriter object correctly w/o a filespec. I'm not allowed to 
>> directly instantiate a Stream & therefore a StreamWriter for that matter 
>> since there's no filespec involved. Can someone show me some code to make 
>> this work?
>
> You could use a StringWriter as a TextWriter to create the XmlTextWriter 
> on:
>
>     StringWriter stringWriter = new StringWriter();
>     XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
>     xmlWriter.WriteStartElement("gods");
>     xmlWriter.WriteStartElement("god");
>     xmlWriter.WriteAttributeString("name", "Kibo");
>     xmlWriter.WriteEndElement();
>     xmlWriter.WriteEndElement();
>     xmlWriter.Flush();
>     xmlWriter.Close();
>     Console.WriteLine(stringWriter.ToString());
>
>
> -- 
>
> Martin Honnen
> http://JavaScript.FAQTs.com/ 


0
10/25/2004 1:14:16 PM
Reply:

Similar Artilces:

Expanding Text
Is there any way to have the text overprint more than one line? For example, Excel typed in cell c5 with an 18pt type will cut off the top half of all letters unless the row height is increased. Is it possible to have the text expand into C4 as opposed to increasing the height of the row? Paul Dulong It can extend into d5 if nothing else is there -- Don Guillett SalesAid Software donaldb@281.com "Paul Dulong" <pdulong@cogeco.ca> wrote in message news:imVLd.2555$Sx6.2...

how to I block text not to break across columns or pages ?
I want to keep certain text together and not have it split apart over columns or on a new page: like several lines comprising an address in an address book -- I want to keep it all together. Either apply a style with the Keep With Next paragraph format option to all but the last of the paragraphs you wish to keep together or Use Shift+Enter to make a line break within the same paragraph -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MV...

How to write text to command prompt console windows?
I am using VC++ 6.0 to build a windows based application, however, my application allows user to input command arguments in the dos prompt windows. I want to have a warning message for user if they have input the wrong arguments. How can I write text to the dos prompt windows if user input the wrong arguments? Thanks in advance. Steven. Steven wrote: > I am using VC++ 6.0 to build a windows based application, however, my > application allows user to input command arguments in the dos prompt > windows. I want to have a warning message for user if they have input the > wrong ar...

Items collection restrict on created
Hi all, Is it possible to do a restrict on outlook calendar items according to the items [created] date/time? Regards, Asaf Yes, see http://www.outlookcode.com/d/finddate.htm . The field you want is CreationTime. Please do not cross-post. A post to one developer group should suffice. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "asaf lahav" <alahav@mecury.co.il> wrote in message news:uhvBnx%23OEHA.2876@TK2MSFTNGP09.phx.gbl... > ...

create a drop down list with the source from a different workbook
Hi, I tried to create a drop down list (Data > Validation > List) with the source from a different work book (If you type the list in a different workbook, define a name with an external reference to the list.). I followed the instructions given in the Microsoft Online Assistant. Iam not able to create the same as iam a getting a message stating that "You may not use references to other worksheets or workbooks for Data validation criteria." Try Debra Dalgleish's web site on this subject: http://www.contextures.com/tiptech.html Scroll down to "D", and see ...

conditional text merge
I want to merge text under the following criteria, First issue (data in Col A in sequence) Col A(text) Col B(text) a gg a hh a s b r b ee c tt d ss d ee Merge to: a gg hh s b r c tt d ss ee Second issue (data in Col A not in sequence) a gg b r a hh a s b ee d ss c tt d ee Merge to: a gg hh s b r c tt d ss ee Is it possible to merge it? TIA norik -- Message posted from http://www.ExcelForum.com Hi yes it is possible but will require some VBA. below one way: 1. Create a unique list for column A on a separate sheet: - selec...

Grey text prints as black..
I'm printing a page that has some text de-emphasized by using a grey font colour. Unfortunately when I print it comes out as black like the rest of the text. I looked for a setting in the Options and in the Print dialogs, but was unable to see anything that said "allow grayscale" anywhere. Suggestions anyone? thanks... R. I have the same problem and have not yet found a solution. could it be a configuration problem with the printer? Have you recently re-installed Excell? Julien "RGK" a écrit : > I'm printing a page that has some text de-empha...

Deleting Text
I know that with "&" I can add two text cells together. How do I get rid of text? In the example "Roddick, Andy (USA) " in A2, I want to get rid of "(USA) ". I can separate with "=right(A1,7)", the last seven characters, but how to "subtract" them from within A2" Felix In an un-used cell, enter: =LEFT(A2,LEN(A2)-7) then copy this cell and paste/special/value back onto A2 -- Gary''s Student - gsnu200827 "Felix" wrote: > I know that with "&" I can add two text cells together. > > How...

How can I put text in a circle using Publisher ?
Have looked everywhere for an answer to this ? : How can I put text in a circle while using Publisher ? If I want to surround a shape or piece of clipart with words, I often need to have text in a circular or oval shape ........ surely this can be done with Publisher. Thanks for any expertise. DixieWins wrote: > Have looked everywhere for an answer to this ? : How > can I put text in a circle while using Publisher ? > > If I want to surround a shape or piece of clipart with > words, I often need to have text in a circular or oval > shape ........ surely this can be ...

how to find a second comma in a text
Hi, I have a text as --> Madison, Dane, Wisconsin How can I find the position of the second comma? thanks, Boon Assuming there is *always* a 2nd comma... =FIND(",",A2,FIND(",",A2)+1) -- Biff Microsoft Excel MVP "Boon" <boonyawat.la-ongthong@cnh.com> wrote in message news:OISZ4IGbKHA.2188@TK2MSFTNGP04.phx.gbl... > Hi, > > I have a text as --> Madison, Dane, Wisconsin > > How can I find the position of the second comma? > > thanks, > Boon > > thanks. this works well fo...

how to stop rules created by the asence assistent
HI NG, we use Exchange 2000 SP3. I allowed the users to send absence notices during their hildays, but disallowed forwarding rules. Although i ysecured the systenm by this way, the users find a possibility to forward emails through the absence assistent. I don=B4t want to forbid this, but is there a way to stop these rules at a central point of administration? Or do I need to disallow absence notices? Birte ...

How can I cross reference a SmartArt Graphic to a page/text?
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I am trying to allow users to click on the SmartArt Graphic on my first page and automatically go to the respective page within the document. I click next to the wording on the graphic and go to Insert, but it will not allow me to insert the cross reference. You can do it the other way around - from the text to the graphic, but not from the graphic to the text. Anyone know a way around this or another way to do it? Objects cannot be used as active hyperlinks in a Word document. You can do what you describ...

[ANN] New XML Text Editor in Visual Studio
Announcing: New XML Text Editor in Visual Studio 2005 Beta 1 Visual Studio 2005 Beta 1 contains a completely new XML Text Editor, built on top of the core text editor provided by Visual Studio. It is entirely written in C# and leverages all the cool stuff provided by the System.Xml ..NET assembly. The XML editor provides support for editing XML and DTD content, including special support for XSD and XSL and includes the following handy features: a.. Full syntax coloring for all XML and DTD syntax. b.. Well formedness checking while you type, with red squiggles and error list. c.. Intel...

TreeView XML Question
Hi Guys, I have different pages in ASP.NET.And i have a treeview that populates XML that i use as the MENU. Is it possible to have one asp.net page but populating different XML to the mENU? Any ideas? ...

Need to format text in header, but value is generated using VBA
This is a multi-part message in MIME format. ------=_NextPart_000_0006_01C6360C.2372C770 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, I wanted to reference a cell value in my spreadsheet header and found = out how to do that using this function: Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim WS As Worksheet For Each WS In Worksheets ActiveSheet.PageSetup.RightHeader =3D _ Format(Worksheets("Time Period Info").Range("B3").Value) =20 Next WS End Sub However, this leaves my text for ...

Find and replace text thats not wdAlignParagraphCenter alignment
Im trying to make a macro that set alignment on all text to wdAlignParagraphJustify, except text that is wdAlignParagraphCenter. Right now i have this: With ActiveDocument.Content.Find .ClearFormatting .ParagraphFormat.Alignment = wdAlignParagraphRight With .Replacement .ClearFormatting .ParagraphFormat.Alignment = wdAlignParagraphJustify End With .Execute Replace:=wdReplaceAll End With With ActiveDocument.Content.Find .ClearFormatting .ParagraphFormat.Alignment = wdAlignParagraphLeft ...

Need text in upper left corner of a cell
Hi Is it possible to have some text written in upper corner of a cell? I use Excel as a fill-in userform. I can justify the size of other columns, but it would be nice to write something into the cell, so the user understand what to fill inn. Any workarounds or other suggestions? Any help is appreciated. Gunnar Hi maybe you can use the comment functionality (goto 'Insert - Comment') to add some hints for the user -- Regards Frank Kabel Frankfurt, Germany Gunnar wrote: > Hi > > Is it possible to have some text written in upper corner > of a cell? > I use Excel a...

Exporting As Text with X Number of Spaces Between Data
Is there a way to export data in a MS Excel spreadsheet as text and define the amount of spaces between the data being exported? The number of spaces need to vary. This concept is the opposite of importing text as "Fixed Width" and creating column break lines. Instead, I'd like to export columns into a text file and specify the amount of spaces between the text that is being exported from each column. The amount spaces in the text file needs to be different between each set of column data. Thanks! One way: Say you have 5 columns, and you want 2 spaces between A &...

"Disappearing" lines of text in Word docs
I've noticed a really unusual intermittent bug in my version of MS Word. Suppose there are two consecutive lines of text in my document, Line A and Line B. I want to insert a new line between Lines A & B, so I position the cursor in between them and hit return (not highlighting Line B beforehand, because I'm not trying to get rid of it). When I do so, Line B seems to disappear, with the cursor (and empty line in front of it) taking the place of Line B. However, when I hit "page up" or "page down", Line B reappears. Anyone know why this might ...

Why is "image and text" option grayed out for some buttons in the customization?
It so happens that the most frequently used buttons on the tool bar are the up-arrow and down-arrow (the ones that move to the next/previous item). As I tried to assign short-cut key to them, however, i found that the "image and text" option is grayed out - for that matter, all other display options are grayed out - when you go into customization mode. Why is "image and text" option unavailable for some buttons? ...

What date was a batch created
I'm in GP v8.0. I need to know what date a user created and/or saved a batch. I've looked all over and there doesn't seem to be any trail when a batch was created/saved short of turning on the User Tracking system. Please get back to me ASAP - sdanna@sfgmortgage.com First, as you probably know, this is not a forum for getting instant answers because it is not monitored officially. Second, SY00500 stores the batch history. It is in the company database. You will need to create a report based on this table. -- Charles Allen, MVP "Sandy D''Anna, GP Project Ma...

How to generate dynamic XML from aspx page
Dear Friends, I was using the below code in ASP to dynamically generate XML from a SQL Query Does anyone knows how can I migrate this code to VB and ASPX? Regards Robson Machado Response.ContentType = "text/xml" Response.Write "<?xml version='1.0' ?>" dim RS, CN set CN = server.CreateObject("adodb.connection") set RS = server.CreateObject("adodb.recordset") CN.ConnectionString = strConnect CN.Open RS.Open SQLStmt,cn Response.Write "<ROOT>" Response.Write RS2XML(RS,"RESULT") Response.Write "</R...

Creating a parent/child relationship for vendors
Hello, Has anyone ever done a parent/child relationship for vendors in great plains? We have a structure that has multiple subcontractors working for the same vendor and since the number of contractors per vendor is a one to one relationship, we were thinking of creating a parent vendor and have the vendors associated with the contractors be the children. This way when we write up an invoice for the parent vendor, we can include all the child vendors information as well. I'm new to the world of Great Plains. If this is an absurd question, please excuse... Thanks, Med Look at the p...

I cannot access newly created users
Hi folks... I have using exchange server. i can add users in Active directory successfully. But I cannot logon through IE or Outllok.. That is from today onwards i can create users but When I configuring in Outlook or when i tried to login through IE I get the following error message. "Sorry. User id and password could not be verified. Please re-enter your user id and password. more details... javax.mail.AuthenticationFailedException: Logon failure: unknown user name or bad password." This means the My Exchange did not recognize the newly created user name. But while I ...

create an internal forum
I have been tasked with creating an internal discussion forum on an Exchange 2003 server. I am new to this and would appreciate any advice or tips that can be shared. I have been searching the internet for days and cannot figure this out. thanks in advance How fancy do you want to make it? You could just use a public folder and train users to sort messages by 'conversation'. Or you could create the public folder and build a web app with .net, or use sharepoint portal. "jason" wrote: > I have been tasked with creating an internal discussion forum on an Exchange &g...