Lost character entities using MSXML6

I load an XML file into  MSXML2.DOMDocument.6.0 object.  The XML file stores 
non-ASCII characters in Hex Code format,
so alpha α is coded as α
I save the file using xmldomSource.save but now α has been replaced with α

How do I preserve the original encoding?  

<%@ LANGUAGE = JScript %>

<%  Response.Charset= "ISO-8859-1" %>
<%  Response.Buffer= "TRUE" %>
<%  Response.Expires= -1 %>
<%
var xmldomSource = new ActiveXObject("MSXML2.DOMDocument.6.0");
		xmldomSource.preserveWhiteSpace = true;
		xmldomSource.setProperty("ServerHTTPRequest", true);
  		xmldomSource.resolveExternals = false;  
  		xmldomSource.validateOnParse = true;  
		xmldomSource.async = false;
		xmldomSource.load(Server.MapPath("input") + "\\" + "test.xml");
		 xmldomSource.save(Server.MapPath("input") + "\\" + "test_out.xml");
%>

0
Merkin (2)
10/29/2009 12:31:10 PM
dotnet.xml 7266 articles. 0 followers. Follow

4 Replies
1922 Views

Similar Articles

[PageSpeed] 13

Note: "so alpha α is coded as α" should read as:
"so alpha α is coded as  &#x3b1; "

"A Merkin" wrote:

> I load an XML file into  MSXML2.DOMDocument.6.0 object.  The XML file stores 
> non-ASCII characters in Hex Code format,
> so alpha α is coded as α
> I save the file using xmldomSource.save but now α has been replaced with α
> 
> How do I preserve the original encoding?  
> 
> <%@ LANGUAGE = JScript %>
> 
> <%  Response.Charset= "ISO-8859-1" %>
> <%  Response.Buffer= "TRUE" %>
> <%  Response.Expires= -1 %>
> <%
> var xmldomSource = new ActiveXObject("MSXML2.DOMDocument.6.0");
> 		xmldomSource.preserveWhiteSpace = true;
> 		xmldomSource.setProperty("ServerHTTPRequest", true);
>   		xmldomSource.resolveExternals = false;  
>   		xmldomSource.validateOnParse = true;  
> 		xmldomSource.async = false;
> 		xmldomSource.load(Server.MapPath("input") + "\\" + "test.xml");
> 		 xmldomSource.save(Server.MapPath("input") + "\\" + "test_out.xml");
> %>
> 
0
AMerkin (2)
10/29/2009 12:57:01 PM
A Merkin wrote:
> I load an XML file into  MSXML2.DOMDocument.6.0 object.  The XML file stores 
> non-ASCII characters in Hex Code format,
> so alpha α is coded as α
> I save the file using xmldomSource.save but now α has been replaced with α
> 
> How do I preserve the original encoding?  
> 
> <%@ LANGUAGE = JScript %>
> 
> <%  Response.Charset= "ISO-8859-1" %>
> <%  Response.Buffer= "TRUE" %>
> <%  Response.Expires= -1 %>
> <%
> var xmldomSource = new ActiveXObject("MSXML2.DOMDocument.6.0");
> 		xmldomSource.preserveWhiteSpace = true;
> 		xmldomSource.setProperty("ServerHTTPRequest", true);
>   		xmldomSource.resolveExternals = false;  
>   		xmldomSource.validateOnParse = true;  
> 		xmldomSource.async = false;
> 		xmldomSource.load(Server.MapPath("input") + "\\" + "test.xml");
> 		 xmldomSource.save(Server.MapPath("input") + "\\" + "test_out.xml");
> %>

I am afraid you have posted through the web interface as that way any 
attempt to post code samples with numeric character references or entity 
references fails to show them.

But generally the DOM model does not store character reference so when 
you load an XML document with a character reference e.g. & # 1 6 0 ; 
(without any spaces) then the XML parser decodes that numeric character 
reference into the corresponding character and the DOM model simply has 
a text node with that character and no information that the original 
source contained a numeric character reference. Consequently, when you 
save the DOM model back, the character reference is not preserved.

-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/
0
mahotrash (1777)
10/29/2009 12:59:24 PM
A Merkin wrote:
> Note: "so alpha α is coded as α" should read as:
> "so alpha α is coded as  &#x3b1; "

The DOM model does not _not_ preserve numeric character references. The 
XML parser replaces any character reference with its character which the 
DOM stores and upon saving the DOM back you will get the character 
stored, not a reference to it.

-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/
0
mahotrash (1777)
10/29/2009 1:41:14 PM
Thanks Martin,

Not exactly what I wanted to hear and I'm surprised I haven't encountered 
this before. I load the XML into a DOM so I can add remove and update various 
nodes. It looks as though I will need to run the result of this through an 
XSLT transform to recover the character references as our typesetters will 
reject this XML. I have a style sheet that will do this. Yet another layer of 
complexity! It's a shame this behaviour can't be avoided.    

"Martin Honnen" wrote:

> A Merkin wrote:
> > I load an XML file into  MSXML2.DOMDocument.6.0 object.  The XML file stores 
> > non-ASCII characters in Hex Code format,
> > so alpha α is coded as α
> > I save the file using xmldomSource.save but now α has been replaced with α
> > 
> > How do I preserve the original encoding?  
> > 
> > <%@ LANGUAGE = JScript %>
> > 
> > <%  Response.Charset= "ISO-8859-1" %>
> > <%  Response.Buffer= "TRUE" %>
> > <%  Response.Expires= -1 %>
> > <%
> > var xmldomSource = new ActiveXObject("MSXML2.DOMDocument.6.0");
> > 		xmldomSource.preserveWhiteSpace = true;
> > 		xmldomSource.setProperty("ServerHTTPRequest", true);
> >   		xmldomSource.resolveExternals = false;  
> >   		xmldomSource.validateOnParse = true;  
> > 		xmldomSource.async = false;
> > 		xmldomSource.load(Server.MapPath("input") + "\\" + "test.xml");
> > 		 xmldomSource.save(Server.MapPath("input") + "\\" + "test_out.xml");
> > %>
> 
> I am afraid you have posted through the web interface as that way any 
> attempt to post code samples with numeric character references or entity 
> references fails to show them.
> 
> But generally the DOM model does not store character reference so when 
> you load an XML document with a character reference e.g. & # 1 6 0 ; 
> (without any spaces) then the XML parser decodes that numeric character 
> reference into the corresponding character and the DOM model simply has 
> a text node with that character and no information that the original 
> source contained a numeric character reference. Consequently, when you 
> save the DOM model back, the character reference is not preserved.
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://msmvps.com/blogs/martin_honnen/
> .
> 
0
AMerkin (2)
10/29/2009 3:38:01 PM
Reply:

Similar Artilces:

Retrieve Picklist Values from caseorrigincode, Incident Entity
Hi, Can someone please advise me on how to retrieve the caseorigincode, picklist values in vb.net? Thanks, Larry B. ...

help on adding a commandbar using VB com addin
Adding Commandbar to the New Mail message Inspector Window I was trying to add a new tool bar and also customize my new toolbar t automatically contain some commands programmatically. I wanna write COM add-in to OutLook that adds a new toolbar to the OutLook' Toolbar. This tool bar should apear only in new mail window. There are two commands(buttons) by name "Digitally sign Message" an "Encrypt Message Contents and Attachments". These are present in the Tools -> Customize -> Commands -> I categories select Standard -> on the Right side, if you scroll do...

Using two types of numbering systems in one document
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Hello, <br> I'm writing a dissertation and must follow very strict guidelines. First, I need to be able to start the numbering (roman numeral) on page iv, not showing any page numbers before that. Second - after about 15 pages I need to switch to arabic numerals. This is all in one document and I have no idea how to do this. Any help would be appreciated! <br> Thanks, <br> Michal Hi Michal, See: http://word.mvps.org/faqs/Formatting/NumberingFrontMatter.htm -- Cheers macropod [Micr...

Prefer how Outlook 2000 looked-now using 2003-Can I switch views?
I don't like the way Outlook 2003 displays and would prefer to go back to the 2000 display. Is this possible. Kinda, http://www.slipstick.com/emo/2003/up031029.htm#classicview might be helpful. "Manhart" <Manhart@discussions.microsoft.com> wrote in message news:A4549A3C-4B06-4AEC-8ADA-DD154CC7795B@microsoft.com... >I don't like the way Outlook 2003 displays and would prefer to go back to >the > 2000 display. Is this possible. Outlook 2003 is highly customizeable - tell us what you want to change, and we'll tell you how to achieve it. There is ...

selecting rows using a variable
I am using excel 2003 and I need to select rows using a variable. Here is what I have now: Dim name As String name = Range("e800") ActiveWorkbook.Sheets("individual stats").Range("a1:a1540").Select Selection.EntireRow.Hidden = True Dim Start As Integer Dim finish As Integer Start = Application.WorksheetFunction.Lookup(name, Range("Q800:Q881"), Range("t800:t881")) finish = Application.WorksheetFunction.Lookup(name, Range("Q800:Q881"), Range("u800:u881")) ActiveWorkbook.Sheets("individual stats&q...

Funny characters in text
Hi I use the following code to insert lines of address text into an excel sheet. Dim MyXL As Object Set MyXL = GetObject("C:\My Spreadsheet.xls") MyXL.WorkSheets("Sheet1").Range("C7").Value = Me.Client & vbCrLf & Me.[Client Address] The problem is that on a client's pc the address shows funny boxes in spreadsheet between address lines, I presume these are CRLF characters. However on my PC I don't see them. Even when they send me a spreadsheet which I can see by remotely login in has boxes, does not show boxes at my end. What is the probl...

Why does Autoexpand in combo box not work with accented characters?
To quote the Access online help: You can use the AutoExpand property to specify whether Microsoft Access automatically fills the text box portion of a combo box with a value from the combo box list that matches the characters you enter as you type in the combo box. This lets you quickly enter an existing value in a combo box without displaying the list box portion of the combo box. This works fine when I use the normal English alphabet, but fails if I type an accented character as the first character of a name in a foreign language such as Hungarian. Is there any way to make AutoExpand ...

Linking using ranges?
I have a chart of data on one excel worksheet (and this chart has a constant number of columns, but the number of rows vary). I need to take all of the data on this chart (not all of the data on that worksheet) and put it in to the middle of another worksheet. I was wondering if there was a way to do this without using a macro. My thought was to try to create a range on each sheet and set one range equal to another, but apparently excel doesn't allow this (at least in version 2000, which I am using). Does anyone have any thoughts or ideas? If this isn't possible how woul...

How to get attributes from other entities in JScript
I have 3 entities In one of them I need an onChange script on an attribute that requires variables pullled from other entities. AFAIK, you cannot include variables in Jscript that are not attributes in the entity. Is that right? What ar ethe alternative solutions? pre-callout? Thanks -- Paul Doyon CRM Consultant ...

Using mixed Resource Types
With the company we have implemented EPM and infrequently the large complex plans fail to 'publish' into PWA. One of the causes thought is that these plans have both cost and work type resources within the same task. Is it good practice to separate these resource types into different tasks? -- joooles Hello joooles, It seems it's a bad pratice. Please see the posts I noticed several month ago: G�rard Ducouret ------------------------------------ If we assign a Cost resource to a task (as the only one resource on that task) and then we enter some % Complete,...

Compacting
Windows XP Media Centre edition fully updated Compacting Outlook Express Before Compacting click on Local Folders Then Menu > File > Folder > Compact All Folders. Runs fine to Folders File then Warning/Error ?? Folders Fuile in use by Outlook Express or another application. Tried reboot then compact again before any other app sused problem persists. Any offers of help please -- Jim Bunton Is Fuile a user created folder or a typo? What is its size? Create a new folder. Move all the contents of the Fuile folder to it and delete the old one. If it is more ...

How do you use the Livescribe smartpen with MS Office products?
I just received a Pulse Smartpen as a gift and I love it. I am curious about how other users of Office products utilize their smartpen features with Office ...

i am using trial version of outlook but it wont allow me to reply
i am using atrial version of outlook but when i try to reply to the email it wont let me, the reply word is not lit in the tool bar? Has your trial expired? Did you activate it? -- Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. ALWAYS post your Outlook version. How to ask a question: http://support.microsoft.com/KB/555375 After furious head scratching, terry mansfield asked: | i am using atrial version of outlook but when i try to reply to the | email it wont let me, the reply word is not lit in the tool bar? terry mans...

how can i format a date that uses "1st" or "2nd" or "3rd" or 4th".
how can i format a date that uses "1st" or "2nd" or "3rd" or 4th"... i am working on a program that generates certificates. i want to use dates such as "3rd of April 2010". when i run my program the words that appears onthe screen was 3-Apr-10. can you help me solve this problem? On Mon, 5 Apr 2010 20:47:01 -0700, cristin wrote: > how can i format a date that uses "1st" or "2nd" or "3rd" or 4th"... i am > working on a program that generates certificates. i want to use dates such > as &q...

Ho do you used Shared Calendar in Outlook with Roadrunner ISP
Hi all, I understand from my ISP that roadrunner is a POP3 server which should allow me to use my Outlook shared calendar with others in the office. However I am unable to use this Outlook feature. Does anyone know how to get around this problem? Many thanks. Kat "Kat" <designme21@yahoo.com> wrote in message news:epq238I0IHA.4004@TK2MSFTNGP03.phx.gbl... > Hi all, > > I understand from my ISP that roadrunner is a POP3 server which should > allow me to use my Outlook shared calendar with others in the office. > However I am unable to use this Outlook feat...

Using Min to Calculate across a table
I am attempting to massage data so I can see what the maximum number of pieces I can produce based off of various components. My query to figure out how many of each component is available per unit is complete and the output is: Part_Number, MaxComponent1, MaxComponent2,MaxComponent3, MaxComponent4 Does anyone have any suggestions as to how I could find the MIN of the components and group by part number? Cheers See the MinOfList() function here: http://allenbrowne.com/func-09.html A better solution would be to create a related table with many records for the combinations that are va...

Attn Jim Gordon: Requesting assistance with exporting OE 4.5 contacts for use in Entourage
Hi Jim, Paul Berkowitz suggested you might be willing to assist me with a dilemma. I have some old mail and contacts in an OE User(s) folder from OE 4.5 that I need to import into Entourage X. I am on a machine that is not OS9-bootable and I cannot get OE 4.5 to launch under Classic mode in Panther. OE 5 loads fine in Classic, but 4.5 gives a shared library error. I don't have an OE 4.5 installer anywhere I can find, so I can't try a reinstall under Classic. I finally found a way to get the mail into Entourage, after much trial and error with every email program I could find, since ...

Attn: M02,3,4 users who use Passport/WinLiveID
You will get broken at the end of July, 2008. (That's about 45 days from now.) See http://support.microsoft.com/kb/894020. You should remove the Passport/WinLiveID from your file before that time. (File|Password Manager). There have been many indications this day would come. Now you all have a date certain. Does this also means backup files taken from M02,3,4 will be inaccessible, even if they are opened with a current version of Money? Although if you have to go back four, five or six years you probably have bigger issues. But I have at times opened older backup files, even five...

using stock
hello, i have been using retail management for about 3 weeks now. but i can't figure one thing out.... we use around 30 suppliers for our dollar store. and we also use our basement + back room as our stock room. in the basement as well as back room we have shelves with numbers on it. i want to know, how i can tell the software that I have 24 light bulbs in shelf 5 in the stock room so don't put that item on the purchase order or dont let any one order it. we would like to get the 24 light bulbs out of stock add them to the store inventory and let them sell out 1st. i have tr...

I did not save changes in Excel and now I lost data. Go Back?
I was asked if I wanted to save changes in Excel and I said no. Now I have lost valuable data. Can I go back and get those previous changes? If you opened a workbook and made changes then said "No" to save changes, you are out of luck. Start typing<g> Gord Dibben MS Excel MVP On Fri, 13 Jan 2006 12:34:01 -0800, "brian" <brian@discussions.microsoft.com> wrote: >I was asked if I wanted to save changes in Excel and I said no. Now I have >lost valuable data. Can I go back and get those previous changes? ...

Workbook minimizes when sending as attachment using Outlook Expres
When I send a workbook as an attachment, using Outlook express, the Excel document minimizes instead of staying open. How do I stop this so the document will stay maximized? ...

Removing at item using qsrules
I am trying to remove an item that is on the pos store operations screen. I am using the following code and it is giving me a "Type mismatch" error: Dim objDeleted As Object Set objDeleted = Session.Transaction.Entries.Remove(Session.Transaction.Entries(1)) I have also tried to define objDeleted as a transactionentry & transactionentires and take off the "Set" and I get "Object variable or With block variable not set" error. Has anyone been successful in removing an item and if so could you provide the code snippit? Thanks, Robert -- rshuptrine armsys ...

How to delete most recently used file list
Can someone please tell me how to delete a file from the most recently used file list in Money 2003? The file is already physically deleted so I don't want it in the listing. I am talking about the "File" pull- down list. Thanks!! On Feb 6, 3:50=A0pm, bajpd <ba...@peak.org> wrote: > Can someone please tell me how to delete a file from the most recently > used file list in Money 2003? =A0The file is already physically deleted > so I don't want it in the listing. I am talking about the "File" pull- > down list. Thanks!! Nevermind, i figu...

How can I choose which lines are frozen using "freeze pane"?
I've tried highlighting the row I would like to freeze, usually just the first row, but it always freezes it after the 16th row. Any suggestions!? This is really frustrating! See if this old post helps: http://tinyurl.com/2qdzt -- HTH, RD ============================================== Please keep all correspondence within the Group, so all may benefit! ============================================== "emilyp" <emilyp@discussions.microsoft.com> wrote in message news:35457940-EC4E-4071-B8C5-4AFD3DABDCB6@microsoft.com... I've tried highlighting the row I would like...

Use jpg as border
Hi - I have a specific jpg that I wish to use as a border on a Word 2007 document. This jpg will be 3/4 point, and will border the entire document with multiple copies of the picture. In other words, the picture will be copied around the entire border of the document. I looked in Word 2007 'Help' but could not find the info on how to do this, if indeed it is possible. Any assistance will be greatly appreciated. Thanks Joe Hello Joe, if your jpg file is of right dimensions, you can use it as a background image. Therefore you can have it as border as...