Xml and unicode values with &#x...

Hello!

I like to use the XmlTextWriter to write some SVG files.

But in some cases, I need the '&' as '&' and not as &.

Example: <glyph unicode=3D"&#x4c;"/>

Some code-snippet:

    XmlDocument ^ doc =3D gcnew XmlDocument();
    ....
    XmlAttribute ^ a =3D doc->CreateAttribute("unicode");
    a1->Value =3D ??? - what to write here?
    ...
    Stream ^ fs =3D gcnew FileStream(filename, FileMode::Create);
    ...
    XmlWriter^ writer =3D gcnew XmlTextWriter(fs, gcnew UTF8Encoding);
    	=


How can I force to write the attribute as &#x4c; and not as &amp;x4c;?

Thanks for any help in advance

Tim
0
no9603 (28)
11/25/2006 12:07:04 PM
dotnet.xml 7266 articles. 0 followers. Follow

4 Replies
737 Views

Similar Articles

[PageSpeed] 52

Tom Fields wrote:

> But in some cases, I need the '&' as '&' and not as &amp;.
> 
> Example: <glyph unicode="&#x4c;"/>
> 
> Some code-snippet:
> 
>    XmlDocument ^ doc = gcnew XmlDocument();
>    ....
>    XmlAttribute ^ a = doc->CreateAttribute("unicode");
>    a1->Value = ??? - what to write here?
>    ...
>    Stream ^ fs = gcnew FileStream(filename, FileMode::Create);
>    ...
>    XmlWriter^ writer = gcnew XmlTextWriter(fs, gcnew UTF8Encoding);
>       
> 
> How can I force to write the attribute as &#x4c; and not as &amp;x4c;?

What programming language is that? You simply need to set the Value 
property to a string with the Unicode characters you need, with C# or J# 
you could simply use e.g.
   "\u004C"
to have that character in a string literal.

Or you can simply use
   "L"
as that is the character with the Unicode code point 76.

There is no need to escape such characters and there is no easy way to 
use XmlDocument or XmlTextWriter to enforce escaping of such characters, 
you would need your own custom XmlWriter that escapes the characters you 
need.
The DOM does not preserve such numeric characters references, it always 
gives you the character itself and not the reference.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
11/25/2006 12:51:35 PM
Thanks for your answer.

Use managed c++.

For ansi-glyphs, I can use <glyph unicode=3D"A"/> and so on.
But for unicode glyphs I have to use <glyph unicode=3D"&#x1A12;"/>.

When I use

   XmlAttribute ^ a1 =3D doc->CreateAttribute("unicode");
   a1->Value =3D "\u01A5";

I get the following warning

   warning C4566: character represented by universal-character-name  =

'\u01A5' cannot be
   represented in the currencode page (1252)	=


und the result (in the xml-file is <glyph unicode=3D"?" />.

Tim
0
no9603 (28)
11/26/2006 2:08:26 PM
Tom Fields wrote:

> Use managed c++.
> 
> For ansi-glyphs, I can use <glyph unicode="A"/> and so on.
> But for unicode glyphs I have to use <glyph unicode="&#x1A12;"/>.
> 
> When I use
> 
>   XmlAttribute ^ a1 = doc->CreateAttribute("unicode");
>   a1->Value = "\u01A5";

Can you try
   a1->Value = L"\u01A5";
?
I don't use managed C++ but some examples on managed C++ on MSDN use 
that syntax which then converts to a managed .NET System.String literal 
I hope. Generally I think the solution is to find a way to write managed 
C++ and include/reference Unicode characters in the source code, not to 
try to escape Unicode characters the XML way as XML can deal with 
Unicode characters without escaping.



-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
11/26/2006 2:52:05 PM
On Sun, 26 Nov 2006 15:08:26 +0100, Tom Fields wrote:

> Thanks for your answer.
> 
> Use managed c++.
> 
> For ansi-glyphs, I can use <glyph unicode="A"/> and so on.
> But for unicode glyphs I have to use <glyph unicode="&#x1A12;"/>.
> 
> When I use
> 
>    XmlAttribute ^ a1 = doc->CreateAttribute("unicode");
>    a1->Value = "\u01A5";
> 
> I get the following warning
> 
>    warning C4566: character represented by universal-character-name  
> '\u01A5' cannot be
>    represented in the currencode page (1252)	
> 
> und the result (in the xml-file is <glyph unicode="?" />.
> 
> Tim

You can use the InnerXml property instead, as this accepts an XML compliant
string such as  "&#x01A5;".

Cheers,
 Gadget
0
gadget1 (19)
11/29/2006 9:39:35 PM
Reply:

Similar Artilces:

Problem when converting to UNICODE, please help
Hello, I didn't think it would be so much pain to convert to UNICODE. The problems I have so far are: 1. I can't use atof() to convert a string to float number. Someone said to use _tstof() (wtof()). But my version of VS6 doesn't have that (not in my MSDN either - July2001). Someone must have done unicode at that time. What was the solution then? 2. It is so odd that I can't use _tcsncpy() or lstrcpyn() to copy 2 strings, eg. CHARFORMAT cfThis; LPCTSTR sFaceName;// from calling function _tcsncpy(cfThis.szFaceName, sFaceName, LF_FACESIZE); The message is {cannot conv...

Anti Aliasing Quit in Office X
The Quartz anti aliasing has recently ceased to function in MSIE and Office. I installed the patch update for MSIE and that fixed the issue there. However, MSFT Office is not responding to the update to fix the issue. Any ideas as to how I can fix the anti aliasing issue? It is really annoying and makes reading documents difficult.. Thank you. M. Sagi pallor@subnova.com First, go to Apple -> About this Mac, and make sure your OS version is at least 10.1.5. If it is any lower, go to Apple -> Software Update and update to the latest version. From there, go to Apple -> System Prefe...

Count of 'Yes' values
Hi all. Look slike it's a busy day for me! :) What I want to do is display a count of all 'Yes' values that have been entered against a specific date. For example if columns A & B hold the following: A B 01/11/2008 Yes 01/11/2008 No 01/11/2008 01/11/2008 Yes 02/11/2008 02/11/2008 03/11/2008 No 03/11/2008 No 03/11/2008 No 03/11/2008 Yes 04/11/2008 Yes I'd like to display a summary that shows: 01/11/2008 2 02/11/2008 0 03/11/2008 1 04/11/2008 1 Is this possible? TIA Duncs Hi Duncs A Pivot table does this and mor...

Pass changing values to parameter to Crystal Report scroll thru re
Hello Community In a C# and ASP.NET app I embed a Crystal Report. In the Crystal Report I create a parameter field named id. Then I read one id from a table and I pass the id from the table to Crystal Report where Crystal Report creates the report successfully. The problem is that now I am reading atleast 5 id’s each containing a different value from the table and I want Crystal Report to create a report for each one of the id’s such that the user can use the carat and scroll thru all of the reports from the first one to the last. Crystal Reports creates reports like...

Allow Temporary Edits In Form To Table Values
Hello all! I'm looking to allow a user to edit some values that are initially pulled from a table, but I do not want those table values updated. Reasoning: The form pulls the number of hours a job will take and a cost per hour then calculates the total cost. Usually both of pulled numbers can be reduced for a discounted total cost. I'm trying to allow the user to calculate what the discounted rate would be. What I've Done So Far: I've tried assigning the boxes to the fields, but then any changes are reflected in the tables. I've tried setting the val...

Active X problem
I have seen this error below on several users with various revs of Outlook. It looks like it occurs when people have fancy Outlook background or signatures. "Your current settings prohibit running Active X controls on this page." How can I fix this problem? I have tried to change security settings on the browser but it doesn't stay, even if logged in as an administrator. Thanks in advance! Please include more information about Outlook/Office Version, O/S, IE version, etc. Have you checked what Outlook security is set for? Outlook 2002 will install by default to use ...

GetWindowText with unicode
I am trying to use GetWindowTextW to get the text typed inside the main window of an app created with the appwizard based on CRichEdit. I have unicode support enabled but whenever I use GetWindowTextW I find that characters which are from a different character set are returned as 3F (the value of '?') instead of their proper value, all normal characters work fine and each character is given two bytes as it should be. Why is it doing this and how can I fix it. Thanks. "Jagadeesh VN" <jagadeeshvn@hotmail.com> a �crit dans le message de news:ect2o1CAEHA.2448@TK2MSFTNGP...

look up a value that results in a cell address
I'm trying to compare two values in two different workbooks. Once compared i need it to give me the cell address where it's located in workbook 2. Once i identify where the value is located, i need to go to that cell address to populate the cells adjacent to it. Can anyone help me figure out how to do this, please. Thank you. Here's one interp / way .. Assume this table is in Book1.xls, in Sheet1, cols A to C, data from row2 down Field1 Field2 Field3 Text1 Data1 Data11 Text2 Data2 Data12 Text3 Data3 Data13 Text4 Data4 Data14 Text5 Data5 Data15 etc (Text1, Text2, etc are ass...

How do I choose multiple values in a drop down box?
I'm hoping to create drop down boxes in a spreadsheet that can have multiple values. I haven't been able to make this work and am wondering if it's even possible. Any help would be great, thanks! You can use Data Validation to create dropdown lists. There are instructions in Excel's help, and here: http://www.contextures.com/xlDataVal01.html Kristy wrote: > I'm hoping to create drop down boxes in a spreadsheet that can have multiple > values. I haven't been able to make this work and am wondering if it's even > possible. > > Any hel...

Using match to return value
Is it possible to use match to return value without reference to other cells? =IF(MATCH(H219,{"00","01","02","03","04","05","06","07","08","09"},0),<<return corresponding value>> ) where corresponding value should return "00" = Positve - Negative "01" = Positve - Positive "02" = Positive - Neutral "03" = Negative - Positve "04" = Negative - Negative "05" = Negative - Neutral "06" = Neutral -Positve "07&quo...

countif value falls in a range of possible values
I am having trouble tring to come up with a solution to this problem... I have a range of percentages from L15 to L21. The values are 100%, 98%, 92%, 80%, 76%, 72% and 67%. What I want to do is start a new column which will tell me how many of these values fall between 100%-90%, 89%-80%, 79%-70%, etc.... I have tried combining if/countif, but I'm coming up short. obviously it's easy just to count by hand but I wanted to develop a formula so i can just swap out the range and re- apply it easily time and time again. thoughts? On 18 Dec, 22:28, Matthew Dyer <matthew.e.d...@...

Excel sort lists with missing values
I need to sort columns of text (with some missing words) to line u against a complete column of text. This would thus leave a blank ro for the missing words in the incomplete column. Suggestions? Thanks -- Message posted from http://www.ExcelForum.com I guessed that you'd have headers in Row 1. And your data started in Row 2. I also guessed that your masterlist was in column A. This worked ok for me: Option Explicit Sub testme01() Dim MstrArray As Variant Dim colArray As Variant Dim iCol As Long Dim ictr As Long Dim FirstErrorRow As Long Dim ErrorRow As Long...

using the value in a cell as part of another cell reference
I want to use the value in one cell as part of the reference for another. eg. A(K10). is there an easy or any way. Pretty new to this, if I'm asking the obvious. As I can't find a function or other method. Steve Stephen, =INDIRECT("A1") refers to A1, and returns what's in A1 =INDIRECT(A1) refers to whatever A1 points to (if A1 contains "A2" then you'd get what's in A2) Your question: =INDIRECT("A" & K10) (if K10 contains 5, then you'd get what's in A5) You can also use =OFFSET(A1,K10-1,0,1,1) This one isn't confounded b...

The field 'MyTable.MyField' cannot contain a Null value because the Required property for this field is set to true.
Hello, I have a form in my database used for entering new data into a table. Some of the fields in my table are required, others are not. If I start entering a new record, using the form, but only fill in some of the fields, and then click a button, to, for example, open another form (i.e. I have decided that I do not want to add this new record now), I will get the following error message: The field 'MyTable.MyField' cannot contain a Null value because the Required property for this field is set to true. Enter a value in this field. What I want is for the record not to be added unl...

XML Signature in Web Services.
According to the technical article "Understanding XML Digital Signature", the author mentions that the "At this point, we know how to refer to content, transform and hash it, and create a signature that covers (protects) that content. Recall that content is protected by using indirection: the ds:SignatureValue covers the ds:SignedInfo, which contains ds:References that contain the digest values of the application data. Change any of those things, and the chain of math computations is broken, and the signature won't verify." I have tried to sign a SOAP XML and ha...

OWA and viewing xml files as txt file
Hi, We are trying to view download xml files renamed to txt from OWA. We are able to download the file; however, the content of the file is omitted. We already determined that the virus scan does not remove the contents from the txt file. can anyone asist. Thank you very much. Tommy ...

When forwarding a message only a red x appears in a blank box?
When I try to forward a message with a picture, the receiver, receives the written part but no pictures are sent only a blank box where the picture would be and a small red x in the top right corner. How can I correct this ...

Buy 1 get 1 of a equel or lesser Value
I would like to do a Buy 1 get 1 discount that works on a Mix and Match. Presently RMS will not do the lesser value automaticly. We must do a manual sort at the POS. I have seen this function in custom POS's. If RMS would allow for Item sorting on the display before tendering a Macro could be desiged to do most of this. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open ...

Excel Chart X axis
I am trying to chart a weekly program on Excel. Is there any way to get my X axis to scale in weeks. The only choices seem days, months, or years. Jack - Unless you need something like week number, you can set the scale to days, and use 7 days as your major unit. - Jon ------- Jon Peltier, Microsoft Excel MVP http://www.geocities.com/jonpeltier/Excel/index.html _______ Jack Fluga wrote: > I am trying to chart a weekly program on Excel. Is there > any way to get my X axis to scale in weeks. The only > choices seem days, months, or years. ...

Getting a strange error when I try to view an XML file from VS.NET
The error message that I'm getting is: "Cannot find the file 'C:\text.xml' (or one of its components). Make sure the path and filename are correct and that all required libraries are available". I've attached the file that I have saved at C:\text.xml. It's a simple XML file that I threw together for testing. But it's giving me that error. Does anyone have any idea why I might be getting this, and (more importantly) how I can fix it? Thanks! -Scott begin 666 test.xml M/#]X;6P@=F5R<VEO;CTG,2XP)R!E;F-O9&EN9STG=71F+3@G(#\^#0H\<75O M=&4^#0H\5&...

Simple Macro to copy each row in the database "X" times? (Excel 2002)
This is a multi-part message in MIME format. ------=_NextPart_000_000D_01C3ECA5.0E42E590 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I was wondering if someone could help me with a macro to cut down on = some repetitive task activity. I have a regularly increasing DB of address information in Excel with = several hundred entries with row 1 as the header row. Depending on the = demand, we have to create mail labels in various quantities per address, = consecutively. I foresee a macro that when kicked off will prompt the = user to ente...

How do I plot non-numeric values in a graph in Excel?
I need to plot non-numeric values in a graph in Excel. Assume I have the following data... : X Axis Y Axis A L B M C N D O E P F Q G R I want such a graph R x Q x P x O x N x M x L x A ...

How do I get a value of a calculated point on an excel line chart?
I created a line chart in Excel and I wanted to find out if there was a way to find out the value on any particular point on the line (not one of the values I entered to create the line, but one in between)? On a Line or an XY chart? -- Bernard V Liengme www.stfx.ca/people/bliengme remove caps from email "klc6778" <klc6778@discussions.microsoft.com> wrote in message news:FA711FAD-0AC7-4644-B987-0AD179CEF776@microsoft.com... >I created a line chart in Excel and I wanted to find out if there was a way > to find out the value on any particular point on the line (not on...

Conditional format lowest value greater than zero and copy formula
I am using Excel 2007 but cannot get the conditional formatting to work correctly. I have 100 rows of data. In the 1st row I need to fill the cell with color if it's the lowest value greater than $0. Then I need to copy that conditional format to the next 99 rows. The conditional formating only works if the cell that's $0 is blank. After I select the 1st row, copy, paste special, formats, it only works on a few of the rows. The rest don't show any color. If I paste special 1 row at a time, it works. Thanks for any help! I'm guessing your CF formula is incor...

who controls the encoding when transforming xml?
I do a transform of an xml document into another xml using XslTransform. In my xsl file, I specify using <xsl:output encoding="utf-8"/>. However, when my transform is done, the resulting xml is in utf-16. What gives? Anyone? Your Xml doc is probably UTF-16 encoded. You might want to check what encoding the Xml doc was saved with. Maybe even try saving it as UTF-8 - in notepad say. Any joy? Steven Founder, http://venturetogether.com "Jiho Han" <jiho.han@infinityinfo.com> wrote in message news:#aSeTVP7DHA.2432@TK2MSFTNGP10.phx.gbl... > I do a transform ...