私は、2 つの Xml ドキュメントを分離し、それらのタグ コンテンツの一部をマージして、3 つ目の Xml ドキュメントを生成する C# アプリケーションに取り組んでいます。内部タグを含む 1 つのタグの値を抽出し、それを別のタグに転送する必要がある状況に直面しています。私はこのようなことを始めました:
var summaryElement = elementExternal.Element("summary");
var summaryValue = (string)summaryElement;
var summaryValueClean = ElementValueClean(summaryValue);
var result = new XElement("para", summaryValueClean)
ElementValueClean 関数が不要な空白を削除する場所。
これは、summary タグの値にテキストのみが含まれている場合に十分に機能します。摩擦は、概要タグに次のような子要素が含まれている場合に発生します。
<summary>
Notifies the context that a new link exists between the <paramref name="source" /> and <paramref name="target" /> objects
and that the link is represented via the source.<paramref name="sourceProperty" /> which is a collection.
The context adds this link to the set of newly created links to be sent to
the data service on the next call to SaveChanges().
</summary>
私はこのようなものを生産したいと思います:
<para>
Notifies the context that a new link exists between the <paramref name="source" /> and <paramref name="target" /> objects
and that the link is represented via the source.<paramref name="sourceProperty" /> which is a collection.
The context adds this link to the set of newly created links to be sent to
the data service on the next call to SaveChanges().
</para>
ソース タグのカタログ全体に表示される可能性のある埋め込みタグは、およそ 12 個あり、その内容を出力タグにマージする必要があります。したがって、一般化できる C# ソリューションが必要です。ただし、Xml フラグメントに適用して Xml フラグメントを生成できる Xslt 変換は、それが十分に単純であれば機能します。私の Xslt スキルは、使用されなくなったため減少しました。