T
Thirsty Traveler
How would I dynamcially create an XML document of the following form:
<ReceiveTSSCallBack xmlns="http://LandAm.EAI.Mainframe.TSR">
<TSSCallBack
xmlns="http://LandAm.EAI.Mainframe.TSR.Schemas.TSSCallback">
<orderNo xmlns="">string</orderNo>
<customerId xmlns="">string</customerId>
<taxingAuthorityList xmlns="">
<string>string</string>
<string>string</string>
</taxingAuthorityList>
</TSSCallBack>
</ReceiveTSSCallBack>
I am at a loss on how to create child nodes under taxingAuthorityList. My
attempt, so far, looks like this:
public XmlDocument CreateCallbackXml(StringBuilder orderNo, StringBuilder
customerId, StringBuilder[] taxingAuthorityList)
{
XmlDocument xmlDoc = new XmlDocument();
XmlText xmlText;
XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0",
"utf-8", null);
XmlElement root = xmlDoc.CreateElement("ReceiveTSSCallBack");
root.SetAttribute("xmlns", "http://LandAm.EAI.Mainframe.TSR");
xmlDoc.AppendChild(root);
XmlElement orderNoEl = xmlDoc.CreateElement("orderNo");
xmlText = xmlDoc.CreateTextNode(orderNo.ToString());
orderNoEl.AppendChild(xmlText);
xmlDoc.DocumentElement.PrependChild(orderNoEl);
XmlElement customerIdEl = xmlDoc.CreateElement("customerId");
xmlText = xmlDoc.CreateTextNode(customerId.ToString());
customerIdEl.AppendChild(xmlText);
xmlDoc.DocumentElement.AppendChild(customerIdEl);
XmlElement taxingAuthorityListEl =
xmlDoc.CreateElement("taxingAuthorityList");
taxingAuthorityListEl.SetAttribute("xmlns", "");
xmlDoc.DocumentElement.AppendChild(taxingAuthorityListEl);
xmlDoc.CreateNode(XmlNodeType.Element, "taxingAuthorityList", "");
// STRUGGLING HERE... NOT SURE OF HOW TO CREATE CHILD ELEMENTS FOR
taxingAuthorityList
//XmlElement taxingAuthorityList1El = xmlDoc.CreateElement("string");
//xmlText = xmlDoc.CreateTextNode(errorMessage.ToString());
//errorMessageEl.AppendChild(xmlText);
//xmlDoc.DocumentElement. .InsertAfter(taxingAuthorityList1El,
taxingAuthorityListEl);
//xmlDoc.DocumentElement.AppendChild(taxingAuthorityList1El);
return xmlDoc;
}
<ReceiveTSSCallBack xmlns="http://LandAm.EAI.Mainframe.TSR">
<TSSCallBack
xmlns="http://LandAm.EAI.Mainframe.TSR.Schemas.TSSCallback">
<orderNo xmlns="">string</orderNo>
<customerId xmlns="">string</customerId>
<taxingAuthorityList xmlns="">
<string>string</string>
<string>string</string>
</taxingAuthorityList>
</TSSCallBack>
</ReceiveTSSCallBack>
I am at a loss on how to create child nodes under taxingAuthorityList. My
attempt, so far, looks like this:
public XmlDocument CreateCallbackXml(StringBuilder orderNo, StringBuilder
customerId, StringBuilder[] taxingAuthorityList)
{
XmlDocument xmlDoc = new XmlDocument();
XmlText xmlText;
XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0",
"utf-8", null);
XmlElement root = xmlDoc.CreateElement("ReceiveTSSCallBack");
root.SetAttribute("xmlns", "http://LandAm.EAI.Mainframe.TSR");
xmlDoc.AppendChild(root);
XmlElement orderNoEl = xmlDoc.CreateElement("orderNo");
xmlText = xmlDoc.CreateTextNode(orderNo.ToString());
orderNoEl.AppendChild(xmlText);
xmlDoc.DocumentElement.PrependChild(orderNoEl);
XmlElement customerIdEl = xmlDoc.CreateElement("customerId");
xmlText = xmlDoc.CreateTextNode(customerId.ToString());
customerIdEl.AppendChild(xmlText);
xmlDoc.DocumentElement.AppendChild(customerIdEl);
XmlElement taxingAuthorityListEl =
xmlDoc.CreateElement("taxingAuthorityList");
taxingAuthorityListEl.SetAttribute("xmlns", "");
xmlDoc.DocumentElement.AppendChild(taxingAuthorityListEl);
xmlDoc.CreateNode(XmlNodeType.Element, "taxingAuthorityList", "");
// STRUGGLING HERE... NOT SURE OF HOW TO CREATE CHILD ELEMENTS FOR
taxingAuthorityList
//XmlElement taxingAuthorityList1El = xmlDoc.CreateElement("string");
//xmlText = xmlDoc.CreateTextNode(errorMessage.ToString());
//errorMessageEl.AppendChild(xmlText);
//xmlDoc.DocumentElement. .InsertAfter(taxingAuthorityList1El,
taxingAuthorityListEl);
//xmlDoc.DocumentElement.AppendChild(taxingAuthorityList1El);
return xmlDoc;
}