I wanna write an application using xml technology with MS.NET2003
VC++.NET,but I don't know how to add xml functionality to my application, So
anybody can offer same artical or snipped codes?
Thank for your the advanced.
Here's a snippet from my test program. Hopefully you get the idea.
#using <mscorlib.dll>
#using <System.Xml.dll>
using namespace std;
using namespace LX;
using namespace System::Xml::Serialization;
using namespace System::Xml;
using namespace System;
using namespace System;
using namespace System::Collections;
public __gc class foo
{
public:
foo()
{
}
foo(System::String* s)
{
_s = s;
}
public:
[XmlAttributeAttribute(S"name")]
System::String* _s;
};
public __gc class land_xml
{
public:
land_xml()
{
arr = new System::Collections::ArrayList();
m_collection = new GeoPointBaseCollection();
System::String* s = new System::String("Daniel");
m_collection->Add(s);
}
public:
[XmlArray(S"Alignments")]
[XmlArrayItemAttribute(S"Alignment",__typeof(foo))]
System::Collections::ArrayList* arr;
[System::Xml::Serialization::XmlAttributeAttribute("Alignments")]
GeoPointBaseCollection* m_collection;
};
int test()
{
using namespace System;
using namespace System::Xml;
using namespace System::Xml::Serialization;
using namespace System::IO;
land_xml* m_land_xml = new land_xml();
XmlSerializer* xs = new XmlSerializer(__typeof(land_xml));
XmlTextWriter* writer = new XmlTextWriter("land_xml2.xml",
System::Text::Encoding::UTF8);
writer->Formatting = Formatting::Indented;
xs->Serialize(writer, m_land_xml);
writer->Close();
return 0;
}