how can I acess XML file in Managed C++ application

A

allen chang

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.

Best regards.
Allen Zhang
 
D

Daniel =?iso-8859-1?Q?Lidstr=F6m?=

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;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top