tags:

views:

35

answers:

1

I am making a customer profile A how they are header and data about each visit. I have gotten my data straight into one of many data objects PersonHeader ph, and StoreVisits sv:

oCustDetails = ActiveCustDetails.GetActiveCustDetails(custNumber, Convert.ToString(regionNumber));

    ph.FirstName = oCustDetails.firstName;
    ph.LastName = oCustDetails.lastName;
    ph.MiddleName = oCustDetails.miName;
    ph.Height = oCustDetails.height;
    ph.Weight =oCustDetails.weight;

List<sv> you get the idea.

Now how can I load these two objects into a

XmlDocument personVisits = new XmlDocument();

personVisits.Load(  ??? )

Do I have to write these data objects to disk to read into personVists?

I also need to associate an xslt file for presentation. Can that be done in the same conversion to xmlDoc or do I come back in a second pass for that?

+1  A: 

You can serialize the CustDetails class into XML using the XMLSerializer and create the output file after the transform using the XslCompiledTransform

XmlSerializer serializer = new XmlSerializer(typeof (CustDetails));
MemoryStream stream = new MemoryStream();
serializer.Serialize(stream, oCustDetails);
stream.Position = 0;
XmlReader reader = XmlReader.Create(stream);
XmlWriter writer = XmlWriter.Create(outputPath);
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(stylesheet);
transform.Transform(reader, writer);
reader.Close();
writer.Close();
Yuriy Faktorovich