EldoS | Feel safer!

Software components for data protection, secure storage and transfer

TElXMLDOMDocument and XmlDocument conversions

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#32127
Posted: 02/06/2015 08:45:28
by Engin K. (Basic support level)
Joined: 02/02/2015
Posts: 6

I'm using TElXMLDOMDocument.LoadFromStream(...) method to load xml file and TElXMLDOMDocument.SaveToStream(...) method to save xml file with C#.

I don't want to read file because I want create XmlDocument object from string. Also I want to save TElXMLDOMDocument to XmlDocument object. I know some ways to convert TElXMLDOMDocument to XmlDocument as:
Code
XmlDocument docNew= new XmlDocument();
docNew.PreserveWhitespace = true;
docNew.LoadXml(TElXMLDOMDocument.OuterXML);

And XmlDocument to TElXMLDOMDocument as:
Code
MemoryStream ms = new MemoryStream(Encoding.Default.GetBytes(XmlDocument.OuterXml));
ms.Position = 0;          
TElXMLDOMDocument.LoadFromStream(ms, "", true);


Is there any other better way to do these conversations?

Thanks.
#32128
Posted: 02/06/2015 08:52:05
by Eugene Mayevski (EldoS Corp.)

You could probably write a function that copies XML nodes recursively. We don't have such function though.


Sincerely yours
Eugene Mayevski
#32132
Posted: 02/06/2015 12:13:31
by Dmytro Bogatskyy (EldoS Corp.)

Hello,
Quote
Is there any other better way to do these conversations?

Using the MemoryStream would be a fastest solution.
Also, you can use ParseElementFromXMLString function from SBXMLUtils to create element from a string, for example:
Code
TElXMLDOMElement Element = SBXMLUtils.Unit.ParseElementFromXMLString(XmlDocument.OuterXml, Document);
Document.AppendChild(Element);

Reply

Statistics

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