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
1906 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:

can wrap text and merge be used together?
I thought that I was able to use wrap text and merge in a cell together but when I use them together it doesn't wrap. Please let me know if I can use the two controls together. Thank you Yes you can use wrap text and merge in a cell. Highlight the cells you want to merge together Format>cells click on Alignment Tab choose the wrap text and merge cells boxes That should do it although excel usually doesn't adjust the row height to show the wrap so you'll probably have to by dragging on the left or going through Format>Row>height "Elizabeth" wrote: >...

Mutiple Entity Views
Looking for a way to view fields from multiple entities in a single view. Does anyone know if this is possible? Thank you. Hi AAA, You can filter over multiple entities, but not view across multiple entities. You can't do this using a single call in a .NET application either. Depending on what you want to do, either a .NET application or report might be the answer. Kris Rhodes ---- MS CRM Certified (Installation & Configuration, Customisation) CRM 3.0/VB.NET 1.1 Developer Quantum Business Technology Perth West Australia Blog: http://rhodeskc.wordpress.com This information ...

how do i ignore a number when using MODE function?
Hi I have a list of numbers that I want to find the MODE in: 0 0 1 2 0 0 3 3 2 2 2 0 0 But I want to be able to ignore the Zeros How do i go about doing this so the mode function gives me the #2 only Thank you -- Dev4me ------------------------------------------------------------------------ Dev4me's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=29709 View this thread: http://www.excelforum.com/showthread.php?threadid=498091 =MODE(IF(A1:A20<>0,A1:A20)) which is an array formula, so commit with Ctrl-Shift-Enter -- HTH RP (remove nothere from the...

Using alt + tab
I formerly used alt + tab to switch between open excel files. Alt + tab displays a preview of the workbook, however when I release the keys the most recent excel file is opened, not the one that is diplayed. Is there a setting that I can change to re-activate this? Any help would be appreciated. Sincerely Jim Palmer --- Message posted from http://www.ExcelForum.com/ Jim, you can also use Ctrl + tab to switch between open work books, but you can't pick the one you want -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so othe...

using excel from dotnet
situation: I'm working on a new app in vbexpress 2008 using acad com interop Also need to write extracted data to excel. problem: At home(laptop) i have excel 10. At the office excel 12. (both seem to have excel5 listed in refs.) I need to work at both locations. can i reference both 10 and 12 in the same vbproj (i think not) can i just reference 5 and is that just an older version with common (but not the latest) interface? i guess i can just have 2 vbproj files (one on laptop one at work) and just copy the .vb class files that are being edited back and forth, not cop...

creating a program that uses data from a sensor....
Hello, I want to create an MFC program that uses parameter values passed to it from a meter (specifically the resistance in ohms of resisters in an electronic circuit). What are the hardware components that would be needed? And what MFC class(es) would I use to accomplish this? Thanks, RABMissouri2006 On 21 Oct 2006 08:10:50 -0700, "RAB" <rabmissouri@yahoo.com> wrote: >Hello, > >I want to create an MFC program that uses parameter values passed to it >from a meter (specifically the resistance in ohms of resisters in an >electronic circuit). What are the ha...

Error while creating custom entity
Hi I am trying to create a custom entity. After filling the required fields on the New Custom Entity form, when i am trying to save it, i am getting the following error: " An error has occured. For more information, contact your system administrator". Help appreciated. Thanks Same issue here. Currently I'm busy troubleshooting, but no results yet. I tried the following without result: Enable logging by adding keys to the registry: LogPerfData: filename LogPerfDataDetails: 1 LogPerfDataLevel: 2 Repare CRM by using the installation disk. Did you make any progress resolvi...

How to use intranet instead of companyweb as address?
Hi, I run SharePoint 3.0 on SBS 2008. By default, the SharePoint website address is http://companyweb, I want to change it to http://intranet as we used to have on 2.0 on SBS 2003, however it doesn't work. I added intranet as CNAME in DNS. When I ping companyweb and intranet, both reply the same IP address, which is my server's IP. But companyweb display the right page, Intranet shows IIS7 welcome page. How can I use Intranet instead of companyweb? Need help! Thanks in advance! Lisa ------=_NextPart_0001_A1AA1B95 Content-Type: text/plain Content-Transfer-Enco...

Sending emails with attachments using SDK
Dear all I need to send emails using the SDK. I can do this through the CRMEmailTemplate.Send() method, or through the CRMEmail.Send() method. But with both of the classes I failed to find a way to include attachments. Is there a way to include attachments in the mails? It's possible with CRM itself Regards RBakkers Unfortunately there isn't a way to add an attachment vis the SDK - so says MS.... "RBakkers" <rbakkers@hotmail.com> wrote in message news:397327D4-C833-4E82-BB80-3732D6A7237F@microsoft.com... > Dear all, > > I need to send emails using the SDK...

Query to delete characters to the right of a decimal point
I need to write a query to help me clean up some letter codes in my database. The codes could have any of the following formats... XY001.01 AP002 SDFJ003.01 JUOI005 I would like the query to return everything to the left of the decimal point, so the data returned would look like this... XY001 AP002 SDFJ003 JUOI005 Thanks in advance for your help. -- Leslie M But didn't you give an example that has NO period in it? One way to approach this would be to use an IIF() statement that checks for a ".", perhaps something like: NewField: IIF(InStr([YourCode],".")...

How to modify the associated entities for an existing custom entit
I have several custom entities where the Activities checkbox was not selected in the Associated Entities section when they were originally defined. I need to enable this option now but the checkbox is disabled. I exported my custom entities to an XML file, changed the <HasRelatedActivities> value from False to True and re-imported the customizations with out any luck. The process completed without errors, however, the changes did not take effect. Is there any way for me to change this without recreating the entity from scratch? I would like to avoid having to recreate all the ...

how to use outlook w/o exchange server?
Trying to use outlook and cannot send/receive email. error msg 0x8004010F. I work from home, have no employess, no need to share address book. Just trying to use it w/ a new PDA I have. The exchange server appears to be a fee based service - I don't know. I just want to use Outlook to schedule my appts, keep contacts and use email. SMScott <SMScott@discussions.microsoft.com> wrote: > Trying to use outlook and cannot send/receive email. error msg > 0x8004010F. I work from home, have no employess, no need to share > address book. Just trying to use it w/ a new PDA ...

Using a drop down box to select all results
I have a summary page which pulls data together from several sheets an displays summary statistics etc. I want to be able to use a drop down list to select particular product and only show data relating to those products - so far so good. But ..... having put in my drop down and referenced it in my formulae now cannot show the summary data for ALL products. Is there a wildcard that can be used in drop downs to select all -- Message posted from http://www.ExcelForum.com You could add (All) to your list of products, and check for that selection in the formula. For example: =IF(A2=...

using interop to create document word 2007
I am using c# and word interop to open a mailmerge document fill it in and then display it to the user. Once i display it the c# app has nothing more to do with the word document. The user can edit it as needed and then save it as a pdf and that is fine. The issue is I would like to set the default path for the document and it could be a network drive or sharepoint and will change every time also it will never be where the original document was opened. ...

using ghost script to put PDFs into Publisher
Thanks Ed and Mary for your comments in response to my query on 14.08.06, Ed you suggested that I download ghoast scrpit, I have started this but the site gets very complicated I have windows XP, which bit do I download ?? Mary I also downloaded PrimoPRF, but seemed to only be able to write and not change PDFs with this am I doing something wrong ?? Have sorted disc prob-Ta Thanks Wend wrote: > Thanks Ed and Mary for your comments in response to my query on 14.08.06, Ed > you suggested that I download ghoast scrpit, I have started this but the site > gets very complicated I hav...

when I try to insert copy character ahead is deleted
I'm woking in Word 2003. If I try to insert a word...instead of just inserting the word the character ahead of where I intend to insert gets deleted. I end up having to re-type the entire line. Press the Insert key again. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "edwardm9350" <edwardm9350@discussions.microsoft.com> wrote in message news:5ACD71DC-1106-4351-9F95-B7676BF94128@microsoft.com... > I'm woking in Word 2003. If I try to insert a word...instead of just > inserting the word t...

Recover Exchange 2007 DB to a network share using powershell from
I am trying to figure out what the proper command is to recover an Exchange 2007 DB to a network location using powershell instead of the DPM 2007 GUI and have it be a clean shutdown? In the Recovery Wizard (GUI) there is an option of 'Bring the database to a clean shutdown after copying the files.' I would like to be able to set this using a powershell command. Does anyone know what that would be? Thanks for you help, Adam ...

Can I use Free Excel Viewer 97/2000 in Windows XP?
Microsoft downloads doesn't list the free excel viewer compatible with Windows XP. Is there a free download to view and print excel spreadsheets, that's compatible with Windows XP? Linda The Viewer for Office 97/2000 works fine under Windows XP. Gord Dibben Excel MVP On Fri, 22 Oct 2004 15:11:01 -0700, "Linda" <Linda@discussions.microsoft.com> wrote: >Microsoft downloads doesn't list the free excel viewer compatible with >Windows XP. Is there a free download to view and print excel spreadsheets, >that's compatible with Windows XP? Linda An...

Special character in text column
I have a column defined as text field in MS Access 2003. I want to insert a string with prefixed of hex02, followed by Carriage Return, followed by Line Feed and ended with hex03. How do I do that manually? eg. (hex02 character)....This is a test.....(Carriage Return, Line Feed, hex03) Thanks Hex(2) & "....This is a test...." & vbCrLf & Hex(3) -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "Alan T" <alanNOSPAMpltse@yahoo.com.au> wrote in message news:u1gDZXnUIHA.4280@TK2MSFTNGP06.phx.gbl... >...

Dont need to use query and indexing feature of moss in project ser
we are going to deploy sharepoint portal server 2007 in existing environment of project server 2007. which is two server installation of project server 2007 . In which first is application server and second is database server. Is it necessary that we start Sharepoint server search and use Query and Indexing feature in front end application server of project server 2007 after installation of MOSS 2007 in front end server ? Because I need only sharepoint server 2007 in existing enviornment of project server 2007 for proposal review workflow of project server 2007. Kindly re...

Referencing .NET 2.0 but end result uses .NET 3.5
I'm using DevStudio 2005 and I have a project that references System.dll ver 2.0.50727 and I accidentally compiled code that used an overload that only exists in version 3.5 because my intellisense showed it. I tried to compile it on another machine that never had the .NET 3.5 install and it wouldn't compile and the intellisense had that version of the overload yet both references looked identical; looking at ver 2.0 of System.dll The method in question was WaitHandle.WaitOne. ..NET 2.0 WaitOne() WaitOne(Int32, Boolean) WaitOne(TimeSpan, Boolean) ..NET 3.5 WaitOne...

Categorizing a Transfer for use in Budget
I would like to be able to categorize a transfer, the way you would a withdrawal/deposit. Is it possible? Here's the situation.....Let's say I have $50 leftover in my budgeted amount for Vacation and I don't want to reallocate it. I'd like to put it in my Savings account, categorized as Vacation. I also track my Savings account in MS Money. The only way I can see to do this is make a withdrawal from checking and deposit in Savings, without tracking the Savings account in the budget. Any suggestions/solutions would be appreciated. "Categorize a transfer" is a co...

How can I create a multiple field search box that use logical operators in an option box?
Hi, I need assistance in creating a multiple field search box, i have a screen shot but i couldn't find a way to include it in this message. I have been battling with this problem for weeks. I'm trying to use ms access 2003 to create a search box similar to one i saw in foxpro. It searches all the fields in only one table so each table has a search box for it. Here is a description for the search box for the community table which is one of the tables in the database. It has a drop down list that selects all the columns in the table such as area code for the community, community code,...

how to use ":"?
struct ste { unsigned int sg_pfnum:20; unsigned int :8; unsigned int :1; unsigned int sg_prot:1; unsigned int sg_v:2; }; what's means of ":20",":8",":1" They are the number of bits used in each word. I don�t remember exactly now, but , for instance, the first declaration: unsigned int sg_pfnum:20 instructs C compiler to use 20 bits of the total amount of space that an unsigned int would use (I guess it starts using from bit 0 up to the last one, but I�ve got no information of how the compiler actually allocates the data). Regards, Juan "haoj...

How to rename Excel Sheet with more characters?
I have AccPacc exporting sheets to excel 2000 which worked ok before, but when i try to export to excel 2003, it gives me an error because you cannot put more than 20 or so characters in the Sheet name (Accpacc Exports names the sheets with 20-30 characters.) Any method to allow for more characters when renaming the sheets in excel 2003? You get 31 characters for a sheet name in xl2003 (through xl95???). Maybe it's the name or the characters in the name causing trouble???? Billy316 wrote: > > I have AccPacc exporting sheets to excel 2000 which worked ok before, but > when...