EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How to populate TElXMLDOMDocument from System.IO.TextReader?

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#27960
Posted: 01/14/2014 06:01:55
by Peter Palotas (Basic support level)
Joined: 11/01/2012
Posts: 49

I have a method that has a TextReader as input. Now I need to populate a TElXMLDOMDocument from this input (for the purposes of signing it). But all I can find is LoadFromStream and LoadFromFile. Is there any way to get it to read from the System.IO.TextReader?

Using SBB 11 with .NET.
#27961
Posted: 01/14/2014 06:06:14
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

TElXMLDOMDocument doesn't have a method to load a document from TextReader. Only LoadFromStream and LoadFromFile are available.
#27962
Posted: 01/14/2014 06:08:20
by Peter Palotas (Basic support level)
Joined: 11/01/2012
Posts: 49

Thanks for the reply. I guess will have to add that to the wishlist then.
#27967
Posted: 01/14/2014 06:29:46
by Vsevolod Ievgiienko (EldoS Corp.)

You can leave it empty - in this case UTF-8 will be used by default. Our SimpleSigner sample displays all possible values for this parameter on startup - you can use this list as a reference.
#27970
Posted: 01/14/2014 06:35:15
by Peter Palotas (Basic support level)
Joined: 11/01/2012
Posts: 49

But if the Stream is not in UTF-8 format I need to specify the encoding. And our application will provide me with a System.Text.Encoding object representing the encoding used, and it appears to me that the names returned from SBChSConv.Unit.EnumCharsets (as used in the SimpleSigner sample) seems to correspond to the "BodyName" property of the .NET Encoding object, and I just wanted to verify that this is indeed the case.
#27975
Posted: 01/14/2014 06:59:59
by Dmytro Bogatskyy (EldoS Corp.)

Quote
But if the Stream is not in UTF-8 format I need to specify the encoding.

Usually, xml documents have an xml header declaration like "<?xml version=“1.0” encoding=“UTF-8”?>". In case if encoding value doesn't match the loaded encoding, the component will reload a document with correct encoding. "DefaultEncoding" parameter used only if an xml document doesn't have encoding in the header.
#27976
Posted: 01/14/2014 07:03:22
by Peter Palotas (Basic support level)
Joined: 11/01/2012
Posts: 49

Yes, I am aware of the XML declaration, and that the encoding may be specified there. But in the absence of such a declaration, I still need to specify an encoding. And I still want to know how correctly get from a .NET System.Text.Encoding instance to the string to pass into the SBB method(s).
#27979
Posted: 01/14/2014 07:25:11
by Dmytro Bogatskyy (EldoS Corp.)

Quote
But in the absence of such a declaration, I still need to specify an encoding. And I still want to know how correctly get from a .NET System.Text.Encoding instance to the string to pass into the SBB method(s).

I would say that WebName property better suits here.

By the way, there is a method SBXMLUtils.Unit.ParseElementFromXMLString that allows to parse xml element (for example: document element without an xml header) from a string.
#27990
Posted: 01/14/2014 11:57:39
by Peter Palotas (Basic support level)
Joined: 11/01/2012
Posts: 49

Okay, thanks. I will use the WebName when neccessary then, it seems to work anyway, even though the set of encodings supported natively by .NET and those in SBB does not seem to match 100%.
Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.

Reply

Statistics

Topic viewed 515 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!