EldoS | Feel safer!

Software components for data protection, secure storage and transfer

XML escape characters in attributes .NET

Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.
Posted: 05/23/2011 08:40:01
by Matthias Pr (Basic support level)
Joined: 05/23/2011
Posts: 3


we're trying to parse some XML from a string which has some escaped characters in it. For testing purposes I wrote the following code which could illustrate the problem.

TElXMLDOMDocument xml = new TElXMLDOMDocument();

MemoryStream m = new MemoryStream();
StreamWriter s;
s = new System.IO.StreamWriter(m, new System.Text.ASCIIEncoding());

s.Write("<?xml version='1.0' ?>\n<ROOT a='Hello&#xA;&#xD;World'></ROOT>");
m.Seek(0, SeekOrigin.Begin);


TElXMLDOMAttr attr = (TElXMLDOMAttr) xml.DocumentElement.Attributes.get_Item(0);


Unfortunately the program does not seem to be able to properly handle the escaped characters. Instead of a line break the program output is just


I have already tried different encodings (both in the XML header and as a replacement for the ASCIIEncoding). (This is probably correct anyway as I can inspect attr.OuterXML with the value : "a='Hello World'")

Is there a different way to get the value of the attribute?

.NET 4.0
SecureBlackBox Version
SecureBlackBox XML
Visual Studio 2010 SP1
Posted: 05/23/2011 09:53:34
by Dmytro Bogatskyy (EldoS Corp.)

There is a bug in a getter of ElXMLDOMAttr.NodeValue/Value property in processing numeric character entities. It is fixed for the next build. Unfortunately, there is no simple way to output a correct attribute value without NodeValue property, you will need to process all attribute childs (for text nodes and entities) and build a string value. If you need a sample let me know.
Thank you for pointing this.
Posted: 06/08/2011 07:32:57
by Matthias Pr (Basic support level)
Joined: 05/23/2011
Posts: 3

Just installed the new version, despite the change notes I'm still having problems with NodeValue - this time seen in the VCL version...

var s : TMemoryStream;
    xml : TElXMLDOMDocument;
    attr : TElXMLDOMAttr;

    s := TMemoryStream.Create;

    xml := TElXMLDOMDocument.Create;

    attr := TElXMLDOMAttr(xml.DocumentElement.Attributes.Item[0]);


    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);



SecureBlackbox - version 9.0.202
Embarcadero® Delphi® XE Version 15.0.3890.34076
Posted: 06/08/2011 08:19:26
by Dmytro Bogatskyy (EldoS Corp.)

That's strange.
Possible some old dcu's are left.
What does the following code return:
Posted: 06/08/2011 08:23:34
by Matthias Pr (Basic support level)
Joined: 05/23/2011
Posts: 3
Posted: 06/08/2011 12:10:16
by Dmytro Bogatskyy (EldoS Corp.)

Unfortunately, the version of SecureBlackbox package for Delphi 2009, 2010 and XE is left 9.0.201, due to a bug in the build process.
The new version (203 build) is expected at this weekends, so we don't plan to replace a current package at the moment, sorry.
Thank you for pointing this.
Posted: 06/12/2011 08:41:57
by Eugene Mayevski (EldoS Corp.)

JFYI: new build is available on the site.

Sincerely yours
Eugene Mayevski
Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.



Topic viewed 1158 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!