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
2015 Views

Similar Articles

[PageSpeed] 15

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:

How to create a CustomerID field for custom entities
Hi, The customerid field is used in opportunity and case and it allows you to select an account or contact, Great. I want to create this field in a form for a new entity i have made, but i cant work out how. Please help. Hi Michael, Customer is special composite type which is not available for custom entities in CRM 3. You will need to add two separete lookup fields for account and contact. -- uMar Khan :: MS CRM MVP CRM Freelance Consultant Email :: imumar at gmail dot com Blog :: http://umarkhan.wordpress.com MVP :: https://mvp.support.microsoft.com/default.aspx/profile/umar.khan &...

Using iterations to calculate circular references.
I am working with data that requires using circular references in some calculations. I checked the "iterations" box to allow for these calculations to work, and Ecxel seems to be calculating everything correctly. The problem is that after I close the workbook, when I later reopen it to continue working, all the cells that are a part of the circular reference display the #VALUE! error. I can fix this by deleting one cell that is part of the loop and then undoing that command, or by copying the formula from a cell, deleting it, and pasting it back into the same cell. I have to d...

Microsoft CRM using Firefox
Hello, Would anyone by chance know if CRM will work correctly on Firefox. Currently, I have employees that are using Firefox and are encountering the same issue as IE [Internet Explorer bombs out and states that it has encountered problems...]. I am just having employees use IE to prevent problem. Thank you for your comments in advance. Install a Firefox extension called IETab "Marcos" <Marcos@discussions.microsoft.com> wrote in message news:19B93E29-757D-46FF-B747-A17EB112ED94@microsoft.com... > Hello, > > Would anyone by chance know if CRM will work cor...

Using crm:5555 rather than a custom hostheader
All I would just like to know what's the recommended solution for a CRM (v3) deployment:- use the standard crm:5555 or a custom hostheader e.g. crm.mycompany.net. Will the custom hostheader cause me any problems? Will external users be able to logon remotely using this host header? Many thanks, Nick. ...

Between using Sumproduct
Is there a way to enter a date value that is between 2 dates in sumproduct or another function that will look at the same column and return the sum of a different column? If the value is greater than May 1,2007 but less than August 31, 2007 in column A it will return the sum of the matching rows in column B. I have tried this with either greater than OR less than and it works but, when I try them in the same sumproduct() it fails. Thanks for reading and any information to the right direction. -- Lee Coleman =SUMPRODUCT(--(A2:A500>=DATE(2007,5,1)),--(A2:A500<=DATE(2007,8,31)),B2...

lost menu bar #2
HELP!!! The main menu bar is missing off my excel sheet and I can't seem to find anyone to help me get it back. The menu I am missing is the one that includes - File, Edit, Insert and etc. I have tried...right clicking - customize - toolbars, but I don't seem to have the needed item. Anyone with suggestions - please reply... Thanks. Hi if you right-click on the menu bar you should see an item like 'General'. Check this item -- Regards Frank Kabel Frankfurt, Germany JoEllen OSBDC wrote: > HELP!!! The main menu bar is missing off my excel sheet > and I can't s...

Creating a template using Publisher
I need help creating a neighborhood directory template using Publisher and merging an Excel spreadsheet into it. It keeps printing multiple pages of the first page after I merge. What version Publisher? If you have 2003 use the catalog merge for your directory. http://office.microsoft.com/en-us/assistance/CH010504381033.aspx Otherwise you need to setup your page as though it is labels. Determine the size of the area you need for each entry, select labels in page setup, type the size you determined in the page setup. Adjust the gaps and margins when you are ready to print (2000 and bel...

iPhone Email to Entourage Using Exchange
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel When I answer an email on my iPhone, it does not register it in Entourage as answered. This function worked fine until the business I work for put everyone on Exchange. Is there a setting for this that I can change? <br><br>Thanks! ...

Server being used to send out viruses
Problem: When I select "Clients can only submit if homed on this server" in the CONNECTIONS tab in the IMC, my remote POP3 users cannot send email through the server. The email just sits in their Outbox. These POP3 clients do have mailboxes (email accounts) on the server so this should work. When I set my server to ACCEPT CONNECTIONS FROM ANY HOST, my server becomes a target for others (as known as evil people) to use my email server to send out viruses. Any ideas? Thanks, everyone who contributes to this forum. This is great! David Hi, If you are using Exchange, w...

Forcing String Literal as Wide Character Unicode
Hello, I am under the impression that using _T("...") will convert my string literal to either a char or a wchar depending on what is defined, but I would like to force my string literal to be a Unicode String ( i.e wchar_t ) How would I do that? Would it be something like: wchar_t string[] = "hi"; something like that? Or is there a way to force my literal string to be unicode? "sleeper" <TheFakeJon@gmail.com> wrote in message news:1159489470.136737.259600@b28g2000cwb.googlegroups.com... > Hello, I am under the impression that using _T("...&q...

Using Sumproduct when some of the values are null
I am having a problem using Sumproduct when some of the cells have null values. I will try to describe the problem. Please let me know if you need additional information. Do any of you have any ideas of how I can fix that sumproduct to get it to work? A B C Row Trend Claims 5 Emergency $0 6 Emergency $0 7 Emergency $0 8 Emergency 81.68% $24,444 9 Emergency 35.00% $164,758 10 Emergency 35.00% ...

Unable to repy using word editor
When repyling to an e-mail I receive the following message, "This form requires Word as your e-mail editor, but Word is either busy, or cannot be found. The form will be opened in the Outlook editor instead". I found article 284900, that states you may get this message when you have office 2000 and office xp installed on the same computer. This is not the case on my computer, Office 2000 does not exist, only office xp. Can anyone help me? There appear to be a whole host of causes for this error message. Most have no solution. Here are a few that do: http://support.microsoft...

Is anybody using Symantec Enterprise Vault?
Hi, A vendor has recommended this solution to us, I have looked at the datasheet for the product and it speaks the right language but I was wondering if anybody on here uses it in a live environment and what their opinion of it is. Cheers Sean ...

How do I tell if Frontpage was used to design a website?
The developers of my website are long gone and I know nothing about what they did. I think it was deisgned in Frontpage, bit am not sure. Once I know that I would like to "convert" it to something that would allow me make changes to the site easily...maybe a visual website designer..is there such a thing? To see if your website is designed in FrontPage a Link to your website will help us. CoffeeCup.com Say:: Visual Site Designer is a WYSIWYG Website creator and editor that helps you make WebPages with no experience or HTML knowledge. Just drag and drop images or ...

question about using the correct schema namespace
I have a Access/VBA client that exports xml to the local drive, then posts it over http to an aspx page. The aspx page consumes it, then builds itself based on the xml data. This works find only if I first mannually change the root entry's namespace url as shown below. Does anyone know how I can get the two (cleint xml export and aspx xml consume) to work together with the appropriate namespace? Here is the top three lines of my xml export (prior to mannually changing it): <?xml version="1.0" encoding="UTF-8"?> <root xmlns:xsd="http://www.w3.org/200...

How to send a HTML email using MAPI or CDO
I have found examples of code emailing using MAPI and/or CDO. Apparently, CDO through smtp.yahoo.com doesn't allow to send multiple emails at once. I loose the connection after sending 12 emails. Any ideas on that? Also, if someone can let me know how can I send a html email using mapi (MAPI32.DLL) not oe.dll library. Thank you is advance, V. -- Desktop Solutions for Small Companies http://www.micromango.com Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access/200706/1 you should be using Access Data Projects and server-side email.. xp_sendmail ...

using backslash ( \ ) inside Parameter
Hi I am trying to use backslash as a part of a parameter at stored procedure. And I am getting syntax error. For instance, to execute like this.. EXEC spSetupPermissions CORP\ABC, Sale with parameter I have set up like this.. CREATE PROC [dbo].[spSetupPermissions] @USERNAME varchar(50), @DEPARTMENT varchar(12) AS IF @DEPARTMENT = 'Sale' BEGIN EXEC Sale.dbo.sp_addlogin @loginame= @USERNAME EXEC Sale.dbo.sp_addrolemember 'db_owner', @USERNAME END ......etc... I should I go about doing this? I would appreciate if anyone would give...

can't use video/audio setup
I uninstalled WLM9.0 and re-installed WLM 8.5 (version 8.5.1302.1018). Now I can't use the video/audio setup. It returned "we are unable to run video/audio setup for the time being". My machine runs on Windows XP SP2 Please help The WLM could not run the audio chat after reinstallation. Anyone can help? "Walter_C" wrote: > I uninstalled WLM9.0 and re-installed WLM 8.5 (version 8.5.1302.1018). Now I > can't use the video/audio setup. It returned "we are unable to run > video/audio setup for the time being". > > ...

Using backup as import
Can I import a Money 2002 backup file into Money 2007? No but you should be able to restore it. "perple" <perple@discussions.microsoft.com> wrote in message news:0832C8E2-B5EB-4197-954E-03E64F66E32E@microsoft.com... > Can I import a Money 2002 backup file into Money 2007? ...

Stop use of Distribution List
Is there anyway that you can stop, or restrict the use of a distribution list? Since you have so much detail of how you are setup and if there are specific people or groups you want to restrict from using it, I will answer your question with the same amount of detail....YES. Add more detail and we can give you a better answer. "brendanrtw" <brendanrtw@discussions.microsoft.com> wrote in message news:6CB3EB2F-F428-46AD-A41E-A1495B8CF4CD@microsoft.com... > Is there anyway that you can stop, or restrict the use of a distribution > list? On Thu, 3 Nov 2005 12:00:...

Operating a small passenger service
I am hoping someone has managed to customise outlook in a way that allows you to use the programe to manage bookings on a small passenger service. I.e input a new booking, number of people, location etc. Then email the days bookings to the different drivers. Maybe it could also be set up to know how many seats are avialale to reduce the risk of double booking? Im using Outlook 2003. ...

using dates Part 2
Karl was great in helping me get to this point with dates, now I'm wondering if we can take it 1 step further? For Activity Dates prior to 2/1/2007 they are using a normal reporting year and the formulas below take care of Activity dates >2/1/2007? So for example prior to 2/1/2007 1/1/2006 would have a B_Qtr of 2006-1 1) B_Qtr - 2011-1 --- Format(DateAdd("m",11,[ActivityDate]), "yyyy - q") 2) Year - 2011 ---- Year(DateAdd("m",11,[ActivityDate])) 3) Qtr - Q1 ---- Format(DateAdd("m",11,[ActivityDate]), "q") -- Than...

Installing Outlook 2003 using Custom Wizard
I am installing Outlook 2003 using the custom installation wizard. This was working fine for some time. Now, someone in my group must have modified the settings because when I install Office using this MST file the local Outlook Contacts are not showing in the GAL. When I go to the properties and try to add it the check box for "Show this folder as an email address book" is greyed out. I have to go in and manually add the Outlook Address book. Can anyone tell me what setting I can change in my Outlook custom install settings for the MST to make this available by default? ...

"Error on page" and error report on entity close
Greetings, We have CRM 4.0 rollup 6 implemented from a CRM 3.0 upgrade about a month ago. Recently, my users have been reporting an error report being generated when they try to close (or save & close) any entity they have open. The entity is closed (or saved and closed), and I have asked them not to send the error report, but of course this needs to be resolved. I have noticed that once the record is open, "error on page" will appear in the bottom left of the dialog if you will receive the error report dialog, which doesn't happen every time. Also, if I do an IIS...

Unicode "private use" glyphs in Powerpoint and Word 2008 #2
Office 12.0.0.1 on Leopard 10.5.2, all updates applied to both. A friend is migrating from Windows to Mac, and has come across something that we're trying to work around. He has some .ppt files with font glyphs in from a Unicode .ttf font (a specific purpose font for showing the LCD display characters on a piece of monitoring equipment). When we bring the font and .ppt over to the Mac, the glyphs from the normal ASCII range come over into Powerpoint 2008 fine, but the glyphs from the "private use" range from F000 upwards a way don't transfer. In Powerpoint they show as spac...