0
グッドアフタヌーンについては、C#とDBテンプレートでのStringBuilderを使用して、XMLフォーマットされた文字列を返すことができません。 は、プレースホルダ
I持つXML構造を出力し、私のDBにテンプレートの文字列を作成機能。 Orderクラスをパラメータとテンプレートとして受け取りますが、[[items]]という名前のプレースホルダタグを設定しようとすると問題が生じます。ここでは、テーブル内の項目数に基づいてその部分のxmlリストを作成する必要があります。これはテンプレートです。文字列のインスタンスを1つ返すだけですが、テーブルの内容に基づいてインスタンスを返す必要があります。
<Items>
[[items]]
</Items>
これはアイテム
<Item>
<SKU>[[item_sku]]</SKU>
<PROD_NAME><![CDATA[[[item_product_name]]]]></PROD_NAME>
<Description><![CDATA[[[item_name]]]]></Description>
<Attributes><![CDATA[[[item_attributes]]]]></Attributes>
<Quantity>[[item_qty]]</Quantity>
<UnitPrice>[[item_price]]</UnitPrice>
<InkColor>[[item_inkcolor]]</InkColor>
</Item>
のために他のタグのために移入するべきであり、それはここでは、この
<Items>
<Item>
<SKU>7Z-BRPA-K79A</SKU>
<PROD_NAME><![CDATA[Test One]]></PROD_NAME>
<Description><![CDATA[ExcelMark 5-Line Large Return Address Stamp - Custom Self Inking Rubber Stamp]]></Description>
<Attributes><![CDATA[Custom Text Line 1 Text: This book was donated to CAEO Font: Arial
Custom Text Line 2 Text: In tribute to & memory of Font: Arial]]></Attributes>
<Quantity>1</Quantity>
<UnitPrice><![CDATA[$9.99]]></UnitPrice>
<InkColor>Red</InkColor>
</Item>
<Item>
<SKU>42A1848</SKU>
<PROD_NAME><![CDATA[Test Two]]></PROD_NAME>
<Description><![CDATA[Self Inking Rubber Stamp with up To 4 Lines of Custom Text]]></Description>
<Attributes><![CDATA[Custom Text Line 1 Text: This book was donated to CAEO Font: Arial
Custom Text Line 2 Text: In tribute to & memory of Font: Arial]]></Attributes>
<Quantity>1</Quantity>
<UnitPrice><![CDATA[$8.99]]></UnitPrice>
<InkColor>Blue</InkColor>
</Item>
</Items>
のように移入したいがそれを実現するための機能である
public string PopulateStringBuilder(Order order, Template template)
{
var i = new StringBuilder(template.Description);
List<string> s = new List<string>();
var reqID = order.OrderId;
foreach (var x in order.Items)
{
i.Replace("[[item_sku]]", x.SkuNumber);
i.Replace("[[item_product_name]]", x.ProductName);
i.Replace("[[item_name]]", x.Description);
i.Replace("[[item_attributes]]", x.Attributes);
i.Replace("[[item_qty]]", x.Quantity.ToString());
i.Replace("[[item_price]]", x.UnitPrice.ToString());
i.Replace("[[item_inkcolor]]", x.InkColor);
o.Replace("[[items]]", i.ToString());
}
return o.ToString();
}