Share via


DocumentBase.XMLSchemaViolations 속성

유효성 검사 오류가 있는 문서의 모든 노드를 나타내는 Microsoft.Office.Interop.Word.XMLNodes 컬렉션을 가져옵니다.

네임스페이스:  Microsoft.Office.Tools.Word
어셈블리:  Microsoft.Office.Tools.Word.v4.0.Utilities(Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

구문

‘선언
Public ReadOnly Property XMLSchemaViolations As XMLNodes
    Get
public XMLNodes XMLSchemaViolations { get; }

속성 값

형식: Microsoft.Office.Interop.Word.XMLNodes
유효성 검사 오류가 있는 문서의 모든 노드를 나타내는 Microsoft.Office.Interop.Word.XMLNodes 컬렉션

예제

다음 코드 예제에서는 문서의 루트 요소에 대한 각 자식 노드의 값을 문자열로 설정한 다음 유효성 검사 오류가 있는 노드의 이름을 표시합니다. 예를 들어, 정수 형식으로 스키마 요소에 매핑되는 모든 노드는 위반 오류를 보고합니다. 이 예제를 사용하려면 문서 수준 프로젝트 ThisDocument 클래스에서 실행하십시오.

Private Sub DocumentXMLSchemaViolations()
    Dim stringBuilder1 As New System.Text.StringBuilder()

    ' Set the node text for all child nodes of the 
    ' root element.
    Dim node As Word.XMLNode
    For Each node In Me.XMLNodes(1).ChildNodes
        node.Text = "A string value"
    Next node

    ' Add the names of the nodes with violations to 
    ' the StringBuilder.
    Dim node2 As Word.XMLNode
    For Each node2 In Me.XMLSchemaViolations
        stringBuilder1.Append(node2.BaseName & ", ")
    Next node2

    ' End the StringBuilder with a period.
    stringBuilder1.Remove(stringBuilder1.Length - 2, 2)
    stringBuilder1.Append(".")

    MessageBox.Show("The document contains " & Me.XMLSchemaViolations.Count.ToString() _
        & " element(s) with errors: " & stringBuilder1.ToString())
End Sub 
private void DocumentXMLSchemaViolations()
{
    System.Text.StringBuilder stringBuilder1 =
        new System.Text.StringBuilder();

    // Set the node text for all child nodes of the 
    // root element.
    foreach (Word.XMLNode node in this.XMLNodes[1].ChildNodes)
    {
        node.Text = "A string value";
    }

    // Add the names of the nodes with violations to 
    // the StringBuilder.
    foreach (Word.XMLNode node in this.XMLSchemaViolations)
    {
        stringBuilder1.Append(
            node.BaseName + ", ");
    }

    // End the StringBuilder with a period.
    stringBuilder1.Remove(stringBuilder1.Length - 2, 2);
    stringBuilder1.Append(".");

    MessageBox.Show("The document contains " +
        this.XMLSchemaViolations.Count.ToString() +
        " element(s) with errors: " + stringBuilder1.ToString());

}

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

DocumentBase 클래스

Microsoft.Office.Tools.Word 네임스페이스