私は、xmlファイルをほとんど取り、それをC#でシリアル化して、Word文書のフォーマットに使用できるようにするプロジェクトに取り組んでいます。これまでのところ、すべて順調に進んでおり、数千の xml タグを解析し、これまでのところ 86 ページのドキュメントを非常にうまく作成しています。
ただし、ドキュメントが完成する前に行う必要がある最後の 2 つのタグに取り組んでおり、何らかの理由でそれらの 1 つでシリアル化が機能していません。
- <layout_row>
- <layout_cell type="attribute">
<attribute_and_presentation attribute="Name" />
<layout_group is_column="true" label_column_width="100" />
</layout_cell>
</layout_row>
上記は、シリアライズしているxmlコードのサンプルです
using System.Collections;
using System.Xml.Serialization;
using System.Xml.Xsl;
using System.Xml.Schema;
using System.Runtime.Serialization;
using System.Collections.Generic;
[System.Serializable()]
public class layout_cell
{
[XmlAttribute("type")]
public string type;
[XmlElement("attribute_and_presentation")]
public attribute_and_presentation attribute_and_presentation;
[XmlElement("layout_group")]
public layout_group layout_group;
}
[System.Serializable()]
public class attribute_and_presentation {
[XmlAttribute]
public string attribute;
}
[System.Serializable()]
public class layout_group {
[XmlAttribute("is_column")]
public string is_column;
[XmlAttribute("label_column_width")]
public string label_column_width;
}
問題は layout_group にあり、何らかの理由でまったくシリアル化されません。私は何時間もこれに取り組んできましたが、明らかに何かを見逃しているに違いないと感じていますが、私の人生では、それを解決することはできません.
このクラスでは、type と attribute_and_presentation の両方が完全に正常にシリアル化されることに注意してください。