xmlserialization without managed code?
Is there a possibility to use xmlwriter (xmlserialization) without managed code (cli)?
using namespace System::Xml;
using namespace System::Xml::Schema;
using namespace System::Xml::Serialization;
My XML serialization managed code:
void TXML_Interface::LoadXML( String^ filena开发者_如何学Gome )
{
XmlSerializer^ serializer = gcnew XmlSerializer( TTEST::typeid );
FileStream^ fs = gcnew FileStream( filename,FileMode::Open );
XmlReader^ reader = gcnew XmlTextReader( fs );
m_test = dynamic_cast<TTEST^>(serializer->Deserialize( reader ));
}
Yes and no.
Yes it is possible to do XML maniuplation (including serialisation) without managed code - I'd normally do this using MSXML however there are various ways to perform xml serialisation in C++ (I'm not really a C++ person but Google is almost certainly the first place to look).
However this is using a different mechanism from the ones contained in the System.Xml.Serialization
namespace. Unfortunately for you the Xml serialisation in .Net is all implemented in managed code, and so if you want to use it you will need to call into managed code (e.g. by using the /clr
compiler option or COM interop).
Maybe the boost::serialization libary is what you are looking for.
Serialization capabilities are rather limited in C++ so boost::serialization is more like a framework that enable you to make your own classes serializable.
精彩评论