OpenXmlElement クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
Open XML ドキュメント内のすべての要素が派生Office基本クラスを表します。 Open XML ドキュメント内のすべての要素の基本クラスOffice表します。
public abstract class OpenXmlElement : ICloneable, System.Collections.Generic.IEnumerable<DocumentFormat.OpenXml.OpenXmlElement>
type OpenXmlElement = class
interface seq<OpenXmlElement>
interface IEnumerable
interface ICloneable
Public MustInherit Class OpenXmlElement
Implements ICloneable, IEnumerable(Of OpenXmlElement)
- 継承
-
OpenXmlElement
- 派生
- 実装
例
次のコード例は、ワード処理ドキュメント内の同じレベルの要素にアクセスする方法を示しています。 この例で使用するテスト ファイルには、"OpenXml 要素" というテキストが含まれている。
using System;
using System.Collections.Generic;
using System.Linq;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
namespace OpenXmlElement
{
class Program
{
// This code example shows how to access elements at the same level
// in a word-processing document.
// The example is using a file that contains the text "OpenXml Element."
static void Main(string[] args)
{
string fileName = @"C:\Users\Public\Documents\AccessElementsSameLevel.docx";
using (WordprocessingDocument wordprocessingDocument =
WordprocessingDocument.Open(fileName, false))
{
// Create a Body object.
DocumentFormat.OpenXml.Wordprocessing.Body body =
wordprocessingDocument.MainDocumentPart.Document.Body;
// Create a Paragraph object.
DocumentFormat.OpenXml.Wordprocessing.Paragraph firstParagraph =
body.Elements<Paragraph>().FirstOrDefault();
// Get the first child of an OpenXmlElement.
DocumentFormat.OpenXml.OpenXmlElement firstChild = firstParagraph.FirstChild;
IEnumerable<Run> elementsAfter =
firstChild.ElementsAfter().Where(c => c is Run).Cast<Run>();
// Get the Run elements after the specified element.
Console.WriteLine("Run elements after the first child are: ");
foreach (DocumentFormat.OpenXml.Wordprocessing.Run run in elementsAfter)
{
Console.WriteLine(run.InnerText);
}
Console.ReadKey();
}
}
}
}
// Output:
// Run elements after the first child are:
// OpenXml
// Element
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports DocumentFormat.OpenXml.Packaging
Imports DocumentFormat.OpenXml.Wordprocessing
Module Module1
' This code example shows how to access elements at the same level
' in a word-processing document.
' The example is using a file that contains the text "OpenXml Element."
Sub Main()
Dim fileName As String = "C:\Users\Public\Documents\AccessElementsSameLevel.docx"
Using wordprocessingDocument As WordprocessingDocument = _
wordprocessingDocument.Open(fileName, False)
' Create a Body object.
Dim body As DocumentFormat.OpenXml.Wordprocessing.Body = _
wordprocessingDocument.MainDocumentPart.Document.Body
' Create a Paragraph object.
Dim firstParagraph As DocumentFormat.OpenXml.Wordprocessing.Paragraph = _
body.Elements(Of Paragraph)().FirstOrDefault()
' Get the first child of an OpenXmlElement.
Dim firstChild As DocumentFormat.OpenXml.OpenXmlElement = _
firstParagraph.FirstChild
Dim elementsAfter As IEnumerable(Of Run) = _
firstChild.ElementsAfter().Where(Function(c) TypeOf c Is Run).Cast(Of Run)()
' Get the Run elements before/after the specified element.
Console.WriteLine("Run elements after the first child are: ")
For Each run As DocumentFormat.OpenXml.Wordprocessing.Run In elementsAfter
Console.WriteLine(run.InnerText)
Next
Console.ReadKey()
End Using
End Sub
End Module
' Output:
' Run elements after the first child are:
' OpenXml
' Element
注釈
呼び出し時に注釈は複製されません。Clone() と .CloneNode(bool)
コンストラクター
| OpenXmlElement() |
OpenXmlElement クラスの新しいインスタンスを初期化します。 |
| OpenXmlElement(String) |
要素の指定された外部 XML を使用して、OpenXmlElement クラスの新しいインスタンスを初期化します。 |
プロパティ
| ChildElements |
現在の要素のすべての子ノードを取得します。 |
| ExtendedAttributes |
現在の要素のすべての拡張属性 (スキーマで定義されていない属性) を取得します。 |
| FirstChild |
OpenXmlElement 要素の最初の子を取得します。 このような OpenXmlElement 要素がないVisual Basic null (Nothing in Visual Basic) を返します。 |
| HasAttributes |
現在の要素に属性が含されているかどうかを示すブール値を取得します。 |
| HasChildren |
現在の要素に子要素が含されているかどうかを示す値を取得します。 |
| InnerText |
ノードとそのすべての子の連結された値を取得します。 |
| InnerXml |
現在の要素の子要素のみを表すマークアップを取得または設定します。 |
| LastChild |
OpenXmlElement 要素の最後の子を取得します。 このような OpenXmlElement 要素がないVisual Basic null (Nothing in Visual Basic) を返します。 |
| LocalName |
現在の要素のローカル名を取得します。 |
| MCAttributes |
マークアップの互換性属性を設定します。 現在の要素に対してマークアップ互換性属性が定義されていない場合は null を返します。 |
| NamespaceDeclarations |
現在の要素で定義されている名前空間宣言を取得します。 名前空間宣言がない場合は、空の列挙子を返します。 |
| NamespaceUri |
現在の要素の名前空間 URI を取得します。 |
| OpenXmlElementContext |
現在の要素の OpenXmlEementContext を取得します。 |
| OuterXml |
現在の要素とそのすべての子要素を表すマークアップを取得します。 |
| Parent |
現在の要素の親要素を取得します。 |
| Prefix |
現在の要素の名前空間プレフィックスを取得します。 |
| XmlQualifiedName |
現在の要素の修飾名を取得します。 |
| XName |
現在の要素の修飾名を取得します。 |
メソッド
| AddAnnotation(Object) |
現在の OpenXmlElement 要素の注釈の一覧にオブジェクトを追加します。 |
| AddNamespaceDeclaration(String, String) |
現在のノードに namepace 宣言を追加します。 |
| Ancestors() |
現在の要素のすべての先祖を列挙します。 |
| Ancestors<T>() |
指定した型を持つ現在の要素の先祖のみを列挙します。 |
| Annotation(Type) |
現在の OpenXmlElement 要素から、指定した型の最初の注釈オブジェクトを取得します。 |
| Annotation<T>() |
現在の OpenXmlElement 要素から、指定した型の最初の注釈オブジェクトを取得します。 |
| Annotations(Type) |
現在の OpenXmlElement 要素の指定した型を持つ注釈のコレクションを取得します。 |
| Annotations<T>() |
現在の OpenXmlElement 要素の指定した型を持つ注釈のコレクションを取得します。 |
| Append(IEnumerable<OpenXmlElement>) |
要素のリストから、現在の要素の子要素のリストの末尾に各要素を追加します。 |
| Append(OpenXmlElement[]) |
要素の配列から、現在の要素の子要素のリストの末尾に各要素を追加します。 |
| AppendChild<T>(T) |
指定した要素を、現在の要素の子ノードのリストの末尾に追加します。 |
| ClearAllAttributes() |
既知の属性と拡張属性の両方を含む、すべての属性をクリアします。 |
| Clone() |
現在のノードの複製を作成します。 |
| CloneNode(Boolean) |
派生クラスでオーバーライドされると、ノードの複製が作成されます。 |
| Descendants() |
現在の要素のすべての子孫を列挙します。 |
| Descendants<T>() |
現在の要素の T 型のすべての子孫を列挙します。 |
| Elements() |
現在の要素のすべての子を列挙します。 |
| Elements<T>() |
指定した型を持つ現在の要素の子のみを列挙します。 |
| ElementsAfter() |
現在の要素に従い、現在の要素と同じ親を持つすべての兄弟要素を列挙します。 |
| ElementsBefore() |
現在の要素の前に、現在の要素と同じ親を持つすべての兄弟要素を列挙します。 |
| GetAttribute(String, String) |
指定したタグ名と名前空間 URI を持つ Open XML 属性を取得します。 |
| GetAttributes() |
すべての属性のコピーを含むリストを取得します。 |
| GetEnumerator() |
子コレクションを反復処理する列挙子を返します。 |
| GetFirstChild<T>() |
型 T の最初の子要素を検索します。 |
| InsertAfter<T>(T, OpenXmlElement) |
指定した参照要素の直後に、指定した要素を挿入します。 |
| InsertAfterSelf<T>(T) |
現在の要素の直後に指定した要素を挿入します。 |
| InsertAt<T>(T, Int32) |
指定した要素を、現在の要素の子要素のリスト内の指定したインデックスに挿入します。 |
| InsertBefore<T>(T, OpenXmlElement) |
指定した参照要素の直前に、指定した要素を挿入します。 |
| InsertBeforeSelf<T>(T) |
現在の要素の直前に指定した要素を挿入します。 |
| IsAfter(OpenXmlElement) |
ドキュメントの順序で指定した要素の後に現在の要素が表示されるかどうかを指定します。 |
| IsBefore(OpenXmlElement) |
現在の要素が文書の順序で指定された要素の前に表示されるかどうかを指定します。 |
| LookupNamespace(String) |
現在のノードのコンテキストで名前空間プレフィックスを解決します。 |
| LookupPrefix(String) |
現在の要素スコープ内の名前空間 uri の対応するプレフィックスを検索します。 |
| NextSibling() |
現在の OpenXmlElement 要素の直後にある OpenXmlElement 要素を取得します。 次の OpenXmlElement 要素がないVisual Basic null (Nothing in Visual Basic) を返します。 |
| NextSibling<T>() |
現在の OpenXmlElement 要素に続く、指定した型を持つ OpenXmlElement 要素を取得します。 次の OpenXmlElement がないVisual Basic null (Nothing in Visual Basic) を返します。 |
| PrependChild<T>(T) |
現在の要素の子要素のリストの先頭に、指定した要素を挿入します。 |
| PreviousSibling() |
現在の OpenXmlElement 要素の直前にある OpenXmlElement 要素を取得します。 前の OpenXmlElement 要素がないVisual Basic null ( Nothing in Visual Basic ) を返します。 |
| PreviousSibling<T>() |
現在の OpenXmlElement の前に指定された型を持つ OpenXmlElement 要素を取得します。 前の OpenXmlElement 要素がない場合は、null (Visual Basic 内の Nothing) を返します。 |
| Remove() |
現在の要素を親から削除します。 |
| RemoveAllChildren() |
現在の要素のすべての子要素を削除します。 |
| RemoveAllChildren<T>() |
T 型の現在の要素のすべての子要素を削除します。 |
| RemoveAnnotations(Type) |
現在の OpenXmlElement 要素から、指定した型の注釈を削除します。 |
| RemoveAnnotations<T>() |
現在の OpenXmlElement 要素から、指定した型の注釈を削除します。 |
| RemoveAttribute(String, String) |
現在の要素から属性を削除します。 |
| RemoveChild<T>(T) |
現在の要素の子要素のリストから、指定した子要素を削除します。 |
| RemoveNamespaceDeclaration(String) |
指定したプレフィックスの名前空間宣言を削除します。 プレフィックスがない場合は何も削除しません。 |
| ReplaceChild<T>(OpenXmlElement, T) |
現在の要素の子要素のリスト内の別の子要素に子要素を置き換える。 |
| SetAttribute(OpenXmlAttribute) |
属性を指定した要素に設定します。 属性が既知の属性の場合、属性の値が設定されます。 属性が拡張属性の場合、'openxmlAttribute' が拡張属性リストに追加されます。 |
| SetAttributes(IEnumerable<OpenXmlAttribute>) |
要素に対して多数の属性を設定します。 属性が既知の属性の場合、属性の値が設定されます。 属性が拡張属性の場合、'openxmlAttribute' が拡張属性リストに追加されます。 |
| WriteTo(XmlWriter) |
現在のノードを指定した XmlWriter に保存します。 |
明示的なインターフェイスの実装
| IEnumerable.GetEnumerator() |