new xml file is larger than the original

i'm working on a windows application that will edit and create xml files from 
another application. the original file is 83k, the one created by my 
program is 153k but all i add is a new xmlelement when i use the other 
program and add a xmlelement is only increased the file to 85k. how come my 
application increased 70k in size and also added the <?xml version="1.0"?> 
when i didn't tell it to. 

how do i duplicated a xml file and only add the xml element that i want to 
insert. where did the extra 70k come from.


here is my code:

        Dim newEvtEnrollElem As XmlElement = Nothing
        Dim str1, str2 As String

        str1 = strPath.Substring(0, strPath.LastIndexOf("."))
        str2 = str1.ToString.Remove(0, 42)

        newEvtEnrollElem = 
CType(xDoc.SelectSingleNode("AutomationControl/EventEnrollments"), XmlElement)

        str1 = strPath.Substring(0, strPath.LastIndexOf("."))
        str2 = str1.ToString.Remove(0, 42)

        If newEvtEnrollElem IsNot Nothing Then

            Dim EvtEnrollElem As XmlElement = 
            Dim EvtEnrollAttr As XmlAttribute = 

            EvtEnrollAttr.Value = "3744"

            EvtEnrollElem.InnerXml = 

            Dim EvtEnrollProp_AckRequiredAttrNode As XmlAttribute = 
            EvtEnrollProp_AckRequiredAttrNode.Value = "0"
            Dim EvtEnrollProp_EvtEnabledAttrNode As XmlAttribute = 
            EvtEnrollProp_EvtEnabledAttrNode.Value = "0"
            Dim EvtEnrollProp_EvtTypeAttrNode As XmlAttribute = 
            EvtEnrollProp_EvtTypeAttrNode.Value = "0"
            Dim EvtEnrollProp_NotifyClassAttrNode As XmlAttribute = 
            EvtEnrollProp_NotifyClassAttrNode.Value = "0"
            Dim EvtEnrollProp_NotifyTypeAttrNode As XmlAttribute = 
            EvtEnrollProp_NotifyTypeAttrNode.Value = "0"
            Dim EvtEnrollProp_PresentValueAttrNode As XmlAttribute = 
            EvtEnrollProp_PresentValueAttrNode.Value = "0"
            Dim EvtEnrollProp_ToFaultTextAttrNode As XmlAttribute = 
            EvtEnrollProp_ToFaultTextAttrNode.Value = ""
            Dim EvtEnrollProp_ToNormalTextAttrNode As XmlAttribute = 
            EvtEnrollProp_ToNormalTextAttrNode.Value = ""
            Dim EvtEnrollProp_ToOffNormalTextAttrNode As XmlAttribute = 
            EvtEnrollProp_ToOffNormalTextAttrNode.Value = ""


            Dim EnRef_ObjKeyAttrNode As XmlAttribute = 
            EnRef_ObjKeyAttrNode.Value = ""
            Dim EnRef_PropName As XmlAttribute = 
            EnRef_PropName.Value = ""


            Dim EvtPara_BitMaskAttrNode As XmlAttribute = 
            EvtPara_BitMaskAttrNode.Value = "0"
            Dim EvtPara_DeadbandAttrNode As XmlAttribute = 
            EvtPara_DeadbandAttrNode.Value = ""
            Dim EvtPara_HighDiffLimitAttrNode As XmlAttribute = 
            EvtPara_HighDiffLimitAttrNode.Value = ""
            Dim EvtPara_HighLimitAttrNode As XmlAttribute = 
            EvtPara_HighLimitAttrNode.Value = ""
            Dim EvtPara_ListOfBitStringValuesAttrNode As XmlAttribute = 
            EvtPara_ListOfBitStringValuesAttrNode.Value = ""
            Dim EvtPara_ListOfValuesAttrNode As XmlAttribute = 
            EvtPara_ListOfValuesAttrNode.Value = ""
            Dim EvtPara_LowDiffLimitAttrNode As XmlAttribute = 
            EvtPara_LowDiffLimitAttrNode.Value = ""
            Dim EvtPara_LowLimitAttrNode As XmlAttribute = 
            EvtPara_LowLimitAttrNode.Value = ""
            Dim EvtPara_RefPropIncrAttrNode As XmlAttribute = 
            EvtPara_RefPropIncrAttrNode.Value = "1"
            Dim EvtPara_TimeDelayAttrNode As XmlAttribute = 
            EvtPara_TimeDelayAttrNode.Value = "60"
            Dim EvtPara_TimeIntervalAttrNode As XmlAttribute = 
            EvtPara_TimeIntervalAttrNode.Value = "1"


            Dim SetPointRef_ObjKeyAttrNode As XmlAttribute = 
            SetPointRef_ObjKeyAttrNode.Value = ""
            Dim SetPointRef_PropNameAttrNode As XmlAttribute = 
            SetPointRef_PropNameAttrNode.Value = ""


            Dim GP_AttrNode As XmlAttribute = xDoc.CreateAttribute("Attr")
            GP_AttrNode.Value = "0"
            Dim GP_InstNumAttrNode As XmlAttribute = 
            GP_InstNumAttrNode.Value = "3744"
            Dim GP_IsConfigAttrNode As XmlAttribute = 
            GP_IsConfigAttrNode.Value = "0"
            Dim GP_ObjNameAttrNode As XmlAttribute = 
            GP_ObjNameAttrNode.Value = "EventEnrollment"
            Dim GP_ObjTypeAttrNode As XmlAttribute = 
            GP_ObjTypeAttrNode.Value = "9"
            Dim GP_SchemaVerAttrNode As XmlAttribute = 
            GP_SchemaVerAttrNode.Value = "1.4"
            Dim GP_TraceOptionsAttrNode As XmlAttribute = 
            GP_TraceOptionsAttrNode.Value = "0"



        End If

        Dim wrtr As XmlTextWriter = New XmlTextWriter("C:\" + str2 + ".xml", 

        MessageBox.Show("Added new eventenrollment element")

dotnetnoob (31)
6/27/2006 7:24:01 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 8

dotnetnoob wrote:
> i'm working on a windows application that will edit and create xml files from 
> another application. the original file is 83k, the one created by my 
> program is 153k but all i add is a new xmlelement when i use the other 
> program and add a xmlelement is only increased the file to 85k. how come my 
> application increased 70k in size and also added the <?xml version="1.0"?> 
> when i didn't tell it to. 

>         Dim wrtr As XmlTextWriter = New XmlTextWriter("C:\" + str2 + ".xml", 
> Encoding.Unicode)

You are saving your XML as Unicode aka UTF-16, which takes 2 bytes per 
character. Use UTF-8, which takes 1 byte per ASCII character and 2  (or 
more) bytes for others.

Oleg Tkachenko [XML MVP, MCPD] | http://www.XmlLab.Net | http://www.XLinq.Net
some2113 (163)
6/29/2006 2:53:44 PM
Thank. i get rid of using Xmltextwriter to save/dup xml file and just use 
xmldocument(DOM) to save the file.

"Oleg Tkachenko [MVP]" wrote:

> dotnetnoob wrote:
> > i'm working on a windows application that will edit and create xml files from 
> > another application. the original file is 83k, the one created by my 
> > program is 153k but all i add is a new xmlelement when i use the other 
> > program and add a xmlelement is only increased the file to 85k. how come my 
> > application increased 70k in size and also added the <?xml version="1.0"?> 
> > when i didn't tell it to. 
> >         Dim wrtr As XmlTextWriter = New XmlTextWriter("C:\" + str2 + ".xml", 
> > Encoding.Unicode)
> You are saving your XML as Unicode aka UTF-16, which takes 2 bytes per 
> character. Use UTF-8, which takes 1 byte per ASCII character and 2  (or 
> more) bytes for others.
> -- 
> Oleg Tkachenko [XML MVP, MCPD]
> | http://www.XmlLab.Net | http://www.XLinq.Net
dotnetnoob (31)
6/30/2006 2:26:01 AM

Similar Artilces:

Must buy new computer...Ideas?
Hello to all! Finally my over 10-1/2 year old Dell desktop's extreme slowness has seriously gotten on my nerves and I'm now looking for a new one. (Surprisingly, it's working pretty well otherwise...) Maybe this isn't the right forum? But beside the usual things like RAM and HD GBs, are there things I should be sure to have...or be careful NOT to have on a desktop? After n ot looking into computers for over a decade I feel like a Martian in the Earth. lol! Also, is it possible to transfer to the new one ALL my stuff, including programs, etc.? Do you thin...

mutimedia messages coming to inbox without attached files
Sending a picture from my phone to email. I use Outlook 2002 to read and send emails. Message arrive but not the attached picture. My phone company email site recieves the picture without any problem. Is there a setting in OUtlook that is stopping the picture? ...

Combining MS Money files
Is there a way to combine/merge MS Money files (not accounts, but files) into one file that will display all acounts? -- FDR You will have to mentally designate one file as the master file and the export accounts from the other file to qif file format. Then import the files all together (use ctrl + click to select when asked which file to import) into the master file. Take backups of both files before you start! -- Regards Bob Peel, Microsoft MVP - Money For UK tips & fixes see;EN-GB;mny. I do not respond to any emails that I ha...

Opening a unicode CSV file from Excel
Hi, I'm currently working on an application that can export data in "CSV" format, and then launches Excel to view the CSV data. This works perfectly ok for ascii data. However now I have upgraded our application to use Unicode I'm running into problems. When I export data into a unicode CSV file and launch excel with it's path on the command line I get a "This is not a recognized format" message. If the same file is opened manually from Excel the same error is shown but afterwards the text import wizard is displayed (which works ok). Currenly the file is 16 ...

I used "save as" but now can't locate original file
I was using a file (November), changed the data, clicked "save as" (December. Now, November is the same as December. Any possibility there's a temp file of November anywhere? Book I believe you have not done as you describe. If you had a previously saved November workbook open and made some changes then File>Save As and named it December, November workbook will still be on your computer in its previous state. Unless you saved it as November with the changes. From where did you open November workbook? It will still be there. Gord Dibben Excel MVP On Thu, 1 Dec 2005 1...

Default properties for new folders
How does one set the default properties applied when creating new email folders? Currently, when I create a new folder, it is created with the AutoPreview turned on by default. I'd like to change that do that it is left off by default. It's something of a pain to create a new folder and then go in to customize it's properties. You can do this by editing the Messages view; View-> Arrange By-> Current View-> Define Views... You might want to define a new view yourself and apply that view on first use of that folder. -- Robert Sparnaaij [MVP-Outlook] www.howto-o...

New Email Messages
I just installed Outlook 2007 on my new PC and for some reason the new messages I received can only be received when I press the SEND/RECEIVE BUTTON. My Outlook at work receives these new mail messages as they are received. So how can I configure the system to make that happen? -- The Trail Hiker!! There are two settings within the accounts 1) Send on starting 2) Auto send/receive every xx minutes - set this for 10 minutes "hiker0531" <> wrote in message >I just installed Outlook 2007 on my n...

Need to Transfer Files Between Money and Quicken
I've got an interesting problem here. I need to transfer files between Money 2002 and Quicken Premium 2004. The first four attempts at having Quicken read exported QIF files has been a disaster. Quicken is absolutely no help. Their built-in help is referring me to webpages that don't exist. There is supposed to be a tool to convert the file format, but the fine print says it is for converting between previous versions of Quicken and Quicken 2004, but it "may work" for converting Money files. A Quicken guru says I need to export Money files to XML in order to bring the files i...

Prevent new comments on old posts in sharepoint blogs
How do I stop comments on certain posts in a SharePoint blog? I have removed permissions to the specific post to the lowest possible access and people can STILL post a comment. If I uncheck one more item in the list of permissions, the users can no longer see the post. Any suggestions? ...

Unable to open "New" window to write email.
I am using Microsoft Outlook in Office 2003. It has been working great until today. When I click "New" to write a new email I get an error window : The messaging interface has returned an unknown error. If the problem persist, Restart Outlook. I have tried this several times, even restarted the computer to no avail. Anyone have a solution???? ...

restoring system data from external HD .bkf files
Hello My OS is Windows XP Media edition 2005. I recently reformatted my HD and now I am trying to restore my Office Outlook files (.pst) plus system settings. I have been only able to access personal files and folders. I really need the ..pst files. When I run the backup - restore wizard the check marks appear on the two "C" drives, out of 14,471 MB on the external HD, only about 350 MB are restored, the field "processed" reads "0" How can I restore the rest of my system from the external HD? Thanks -- Zubenelshamali On Thu, 27 May 2010 14:53:4...

Transfering Access 2000 file to Access 97
How do I save a Access 2000 file so it can be opened using Office 97 Access. Is it possible Hi Stewart, You will need to convert it to Access 97 as follows: - Select the menu option Tools > Database Utilities > Convert Database > To Access 97 file format I hope this helps! If you have additional questions on this topic, please respond back to this posting. Regards, Eric Butts Microsoft Access Support "Microsoft Security Announcement: Have you installed the patch for Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises you to review the informatio...

Looking for Microsoft Office Binary File Format or File Signature data
I have an application which obtains numerous "unidentifiable" files with no file extension, via FTP, and would like to run some sort of binary filter on it to identify PPT, DOC, XLS file formats. I did fine this: But it seems a messy way of accomplishing this, and is incomplete. Any clues as to finding the binary record format and/or file signatures of Office documents (Office 2000 and greater). - Thanks ...

New Location/New setup
Currently I'm downsizing our office, and moving to a new location. I'm running MS Server2003 as well as Exchange 2003. Once moved, I will no longer require the server (since I am setting up a home office). Are there currently any steps or procedures available to correctly shutdown one office...and basically setup a home office with no exchange server. Also I will be removing the current pc's from the Domain, and setting up a few in a workgroup. I would like to receive emails from the other employees for time being until I completely cancel this email account. I already have a...

A Short Video on Adding/Editing New Customers
If capturing customers at the POS is important to you, take a couple of minutes and watch this video. This application also allows for edit of Global customer information in HQ installations. Contact us for detailed info and demo. sales(at) It would be nice if you could encode the videos with a more common codec, and not in wmv format. This requires the GTM3 codec (GoToMeeting). Windows Media Player 11 doesn't automatically download the codec, and I'm not going through the trouble to download and in...

How do I activate the new mail button
When I start Outlook, the "New", "forward", "reply" and "reply to all" buttons are not active which means I can not send mail. I have no problems receiving mail. Also, on web pages with email links, when I click on them, the Outlook application is not launched which is almost certainly related to this. I think I'm missing something very simple here! Are you in a mail enabled folder? Do you have an active email account installed? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert...

Cannot Open 2002 Files in 2004
USA Money 2002. Moved 2002 files to flash drive and tried to open them using Money 2004 and I get this message "Type your password to access your files." The friedn I am helping does not ever remember using a password. I guess the only option is to use the Money 2002 program on the old hardrvie and see if that will allow us to access the file. Thanks Smith The most typical case is where you are trying to switch regions. Your second option requires that Money 2002 be installed. This sounds like you are trying to upgrade a computer. BTW you can have multiple versions of Mo...

Can I Display Winodws File Folder Contents in Outlook?
OL2007/Exchange: I have found how to set a particular outlook folder to display a website by seleting the home page tab under properties. Is there a way to have this display the contents of a windows file folder instead of an html file? I have tried something like c:\my documents, and even file:\\c:\my documents, but this does not seem to work. I've thought of perhaps making an html file with links to the contents of the folder and displaying that html file. Looks pretty easy, but if we add new files, etc., then the html file does not get automatically updated. I know this is a stran...

Style available all sheets new or old
I need a custom style that is available in all spreadsheets, new or old. I can set style and save it in book.xlt in xlstart, but that only works for new workbooks, and doesn't work with old spreadsheets when I call them up. I want to be able to select a group of cells, or column or row and apply a setting for negative numbers to have brackets. I am using Excel 2000. I even tried saving the style in personal.xls, but that doesn't work as it is hidden. Do I have to use a macro? And if so what would it be? Thanks One way: Public Sub MergeStyles() ActiveWorkbook....

view a pub file
Hi I d like to know how I could see a publisher file if I have not publisher ?? thank you You can't. You will have to ask the sender to convert it to a .pdf file for you. If they can't and this is a one time thing, you are welcome to forward the file onto me and I'll do it for you. Send it to jl dot paules at gmail dot com. -- JoAnn Paules MVP Microsoft [Publisher] "Photo" <> wrote in message news:44b04061$0$881$ > Hi > I d like to know how I could see a publisher file if I have not publisher > ?? &g...

Sub Form Assigning New Values to Old Records
I am using a subform within a form to have users update certain fields in the record where the rest remiain locked. On the Main form when the list box (which is bound to a query) is used to select the record set to display in the subform it sometimes takes an old record and assigns a new value to the record. For example it changes the Period field from 9 to 10. Taking a record created in period 9 and assigning a period ten to it which is the selection I make in the list box. Addtionally, it looks like it is taking the first record in the related table to assign this new value to. ...

best way to deserialize xml
I'm at a quandry as to what's the best/fastest way to deserialize an incoming xml stream? I ran a small test on xmlserializer and on a small file it performed 10 times worse then when I used the XMLDocument and deserialized the values myself. Is the xmlserializer really that slow? I'm expecting a file about 1 MB in length and if it's that slow on a 2 K file then I can't phantom how it's going to behave on a 1 MB file. Should I just skip the xmlserializer and XML Dom and go straight to xmlreader and do the deserialization myself? This has been discussed a few times...

How to generate a mailbox list file to use in scheduled ExMerge
Hi! Anyone know how I can generate a file that contains a list of mailboxes to be used with scheduled ExMerge? I tried to interactively run ExMerge, then cancell the program halfway, but it does not create the file I need. An alternative for creating the file would be to use an LDAP query in a script -- if anyone can help with that as well. Thanks MosesM On Wed, 4 Jan 2006 11:05:04 -0800, MosesM <> wrote: >Hi! Anyone know how I can generate a file that contains a list of mailboxes >to be used with scheduled ExMerge? I tried to interactively ru...

Converting vcproj files from VS2005 to VS2008 with Powershell
I wanted to share this to give back to the general Powershell knowledge base and didn't know where to do this so am posting this here. Not long ago I had to migrate a number of legacy C++ VS2005 projects into VS2008 format. The projects had been originally migrated from VC6 Dev Studio format so that there was some path fixups required to allow the projects to build with Team Build. I created the following powershell script which I named fixVS8toVS9vcproj.ps1 which does 90% of the grunt work. Usage (from a Powershell console prompt): .\fixVS8toVS9vcproj.ps1 {path}\...

Adding new pages
Any thing I do on new pages happens simultaneously on any previous page. Can someone help me please? Can you be more specific? What stencils are you using and what are you trying? John... Visio MVP Need stencils or ideas? Need VBA examples? Common Visio Questions "Joanie" <> wrote in message > Any thing I do on new pages happens simultaneously on any previ...