1

XDocument最終的にデータベースによって提供されるデータで初期化しようとしています。テスト目的で、データをハードコーディングしました。

WFEvent[] wfs = new WFEvent[] {
    new WFEvent {
        ID = new XElement("WorkflowEventID", 0),
        ParentID = new XElement("ParentID", 0),
        Active = new XElement("Active", false),
        Status = new XElement("Status", "Complete")
    },
    new WFEvent {
        ID = new XElement("WorkflowEventID", 1),
        ParentID = new XElement("ParentID", 0),
        Active = new XElement("Active", true),
        Status = new XElement("Status", "In Progress")
    },
    new WFEvent {
        ID = new XElement("WorkflowEventID", 2),
        ParentID = new XElement("ParentID", 1),
        Active = new XElement("Active", false),
        Status = new XElement("Status", "Pending")
    },
    new WFEvent {
        ID = new XElement("WorkflowEventID", 3),
        ParentID = new XElement("ParentID", 2),
        Active = new XElement("Active", false),
        Status = new XElement("Status", "Pending")
    },
    new WFEvent {
        ID = new XElement("WorkflowEventID", 4),
        ParentID = new XElement("ParentID", 3),
        Active = new XElement("Active", false),
        Status = new XElement("Status", "Pending")
    },
    new WFEvent {
        ID = new XElement("WorkflowEventID", 5),
        ParentID = new XElement("ParentID", 4),
        Active = new XElement("Active", false),
        Status = new XElement("Status", "Pending")
    },
    new WFEvent {
        ID = new XElement("WorkflowEventID", 6),
        ParentID = new XElement("ParentID", 5),
        Active = new XElement("Active", false),
        Status = new XElement("Status", "Pending")
    },
    new WFEvent {
        ID = new XElement("WorkflowEventID", 7),
        ParentID = new XElement("ParentID", 6),
        Active = new XElement("Active", false),
        Status = new XElement("Status", "Pending")
    },
    new WFEvent {
        ID = new XElement("WorkflowEventID", 8),
        ParentID = new XElement("ParentID", 7),
        Active = new XElement("Active", false),
        Status = new XElement("Status", "Pending")
    },
    new WFEvent {
        ID = new XElement("WorkflowEventID", 9),
        ParentID = new XElement("ParentID", 8),
        Active = new XElement("Active", false),
        Status = new XElement("Status", "Pending")
    },
};

XDocument xml =
    new XDocument("RatingOverview",
        new XElement("RatingRequest",
            new XElement("CreateNewRatingRequest", wfs[0].ID, wfs[0].ParentID, wfs[0].Active, wfs[0].Status)
        ),
        new XElement("Assessment",
            new XElement("NeedsAssessment", wfs[1].ID, wfs[1].ParentID, wfs[1].Active, wfs[1].Status),
            new XElement("GroupConcerns", wfs[2].ID, wfs[2].ParentID, wfs[2].Active, wfs[2].Status),
            new XElement("Recomendation", wfs[3].ID, wfs[3].ParentID, wfs[3].Active, wfs[3].Status)
        ),
        new XElement("TechnicalAssistancePlan",
            new XElement("VerifyCurrentRating", wfs[4].ID, wfs[4].ParentID, wfs[4].Active, wfs[4].Status),
            new XElement("PlanDeveloped", wfs[5].ID, wfs[5].ParentID, wfs[5].Active, wfs[5].Status),
            new XElement("ContactLog", wfs[6].ID, wfs[6].ParentID, wfs[6].Active, wfs[6].Status)
        ),
        new XElement("EnvironmentalRatingReport",
            new XElement("ERSScores", wfs[7].ID, wfs[7].ParentID, wfs[7].Active, wfs[7].Status),
            new XElement("ERSPlanDeveloped", wfs[8].ID, wfs[8].ParentID, wfs[8].Active, wfs[8].Status)
        ),
        new XElement("SubmitRequest",
            new XElement("SendToDCC", wfs[9].ID, wfs[9].ParentID, wfs[9].Active, wfs[9].Status)
        )
    );

XDocument xml初期化時に次の例外が発生します。

" System.ArgumentException: Non white space characters cannot be added to content."

明らかな何かが欠けていることを願っていますが、問題を特定できないようで、Google はこのエラーに関する有用な情報を提供していません。

4

1 に答える 1