EDN Admin
Well-known member
<p style="margin:0in 0in 10pt <span><span style="font-size:small <span style="font-family:Calibri <span> UPS allows checking rates and services by creating a POST request that contains 2 XML documents.
<p style="margin:0in 0in 10pt <span><span style="font-family:Calibri;font-size:small The MSDN page âWriting XML with the XmlWriterâ says the XmlWriter can âWrite multiple documents to one output stream.â<span> <span> Ref: http://msdn.microsoft.com/en-us/library/4d1k42hb.aspx <span style="font-family:Calibri;color:#800080;font-size:small http://msdn.microsoft.com/en-us/library/4d1k42hb.aspx
<p style="margin:0in 0in 10pt <span><span style="font-size:small <span style="font-family:Calibri I havnât managed that, however.<span> Below is a sample snipet of what Iâm after.<span> The error is produced at the second WriteStartDocument method, with a message âToken StartDocument in state End Document would result in an invalid XML Document.
<p style="margin:0in 0in 10pt <span><span style="font-size:small <span style="font-family:Calibri My question is â how do I âWrite multiple documents to one output stream.â?
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> <span style="color:green // An example of trying to write multiple documents to one output stream.
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span>
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> <span style="color:#2b91af StreamWriter sw = <span style="color:blue new <span style="color:#2b91af StreamWriter(<span style="color:#a31515 @"C:tempSW_With_Multiple_Documents.xml");
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> <span style="color:#2b91af XmlWriterSettings settings = <span style="color:blue new <span style="color:#2b91af XmlWriterSettings();
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> settings.ConformanceLevel = <span style="color:#2b91af ConformanceLevel.Auto;
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> settings.CloseOutput = <span style="color:blue true;
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> <span style="color:#2b91af XmlWriter writer = <span style="color:#2b91af XmlWriter.Create(sw, settings);
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteStartDocument(<span style="color:blue true);
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteStartElement(<span style="color:#a31515 "First_Document");
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteEndElement();
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteEndDocument();
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteStartDocument(<span style="color:blue true);
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteStartElement(<span style="color:#a31515 "Second_Document");
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteEndElement();
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteEndDocument();
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.Flush();
<p style="margin:0in 0in 10pt <span style="line-height:115%;font-family:Courier New;font-size:10pt <span> writer.Close();<br/>
View the full article
<p style="margin:0in 0in 10pt <span><span style="font-family:Calibri;font-size:small The MSDN page âWriting XML with the XmlWriterâ says the XmlWriter can âWrite multiple documents to one output stream.â<span> <span> Ref: http://msdn.microsoft.com/en-us/library/4d1k42hb.aspx <span style="font-family:Calibri;color:#800080;font-size:small http://msdn.microsoft.com/en-us/library/4d1k42hb.aspx
<p style="margin:0in 0in 10pt <span><span style="font-size:small <span style="font-family:Calibri I havnât managed that, however.<span> Below is a sample snipet of what Iâm after.<span> The error is produced at the second WriteStartDocument method, with a message âToken StartDocument in state End Document would result in an invalid XML Document.
<p style="margin:0in 0in 10pt <span><span style="font-size:small <span style="font-family:Calibri My question is â how do I âWrite multiple documents to one output stream.â?
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> <span style="color:green // An example of trying to write multiple documents to one output stream.
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span>
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> <span style="color:#2b91af StreamWriter sw = <span style="color:blue new <span style="color:#2b91af StreamWriter(<span style="color:#a31515 @"C:tempSW_With_Multiple_Documents.xml");
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> <span style="color:#2b91af XmlWriterSettings settings = <span style="color:blue new <span style="color:#2b91af XmlWriterSettings();
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> settings.ConformanceLevel = <span style="color:#2b91af ConformanceLevel.Auto;
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> settings.CloseOutput = <span style="color:blue true;
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> <span style="color:#2b91af XmlWriter writer = <span style="color:#2b91af XmlWriter.Create(sw, settings);
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteStartDocument(<span style="color:blue true);
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteStartElement(<span style="color:#a31515 "First_Document");
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteEndElement();
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteEndDocument();
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteStartDocument(<span style="color:blue true);
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteStartElement(<span style="color:#a31515 "Second_Document");
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteEndElement();
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.WriteEndDocument();
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt
<p style="line-height:normal;margin:0in 0in 0pt <span style="font-family:Courier New;font-size:10pt <span> writer.Flush();
<p style="margin:0in 0in 10pt <span style="line-height:115%;font-family:Courier New;font-size:10pt <span> writer.Close();<br/>
View the full article