Office.CustomXmlPart interface

Office.CustomXmlParts コレクション内の 1 つの CustomXMLPart を表します。

注釈

アプリケーション: Word

プロパティ

builtIn

True の場合、カスタム XML パーツが組み込まれています。それ以外の場合は false。

id

CustomXMLPart の GUID を取得します。

namespaceManager

現在の CustomXmlPart に対して使用される名前空間プレフィックス マッピング (Office.CustomXmlPrefixMappings) のセットを取得します。

メソッド

addHandlerAsync(eventType, handler, options, callback)

指定したイベント型を使用して、オブジェクトにイベント ハンドラーを追加します。

addHandlerAsync(eventType, handler, callback)

指定したイベント型を使用して、オブジェクトにイベント ハンドラーを追加します。

deleteAsync(options, callback)

カスタム XML パーツを削除します。

deleteAsync(callback)

カスタム XML パーツを削除します。

getNodesAsync(xPath, options, callback)

指定された XPath に一致するこのカスタム XML パーツ内の CustomXmlNodes を非同期に取得します。

getNodesAsync(xPath, callback)

指定された XPath に一致するこのカスタム XML パーツ内の CustomXmlNodes を非同期に取得します。

getXmlAsync(options, callback)

このカスタム XML パーツ内の XML を非同期的に取得します。

getXmlAsync(callback)

このカスタム XML パーツ内の XML を非同期的に取得します。

removeHandlerAsync(eventType, handler, options, callback)

指定したイベントの種類のイベント ハンドラーを削除します。

removeHandlerAsync(eventType, handler, callback)

指定したイベントの種類のイベント ハンドラーを削除します。

プロパティの詳細

builtIn

True の場合、カスタム XML パーツが組み込まれています。それ以外の場合は false。

builtIn: boolean;

プロパティ値

boolean

function showXMLPartBuiltIn() {
    Office.context.document.customXmlParts.getByIdAsync(
        "{3BC85265-09D6-4205-B665-8EB239A8B9A1}", function (result) {
        const xmlPart = result.value;
        write(xmlPart.builtIn);
    });
}

// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

id

CustomXMLPart の GUID を取得します。

id: string;

プロパティ値

string

function showXMLPartBuiltId() {
    Office.context.document.customXmlParts.getByIdAsync(
        "{3BC85265-09D6-4205-B665-8EB239A8B9A1}", function (result) {
        const xmlPart = result.value;
        write(xmlPart.id);
    });
}
// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

namespaceManager

現在の CustomXmlPart に対して使用される名前空間プレフィックス マッピング (Office.CustomXmlPrefixMappings) のセットを取得します。

namespaceManager: CustomXmlPrefixMappings;

プロパティ値

function setXMLPartNamespaceManagerNamespace() {
    Office.context.document.customXmlParts.getByIdAsync(
        "{3BC85265-09D6-4205-B665-8EB239A8B9A1}", function (result) {
        const xmlPart = result.value;
        xmlPart.namespaceManager.addNamespaceAsync("myPrefix", "myNamespace");
    });
}

メソッドの詳細

addHandlerAsync(eventType, handler, options, callback)

指定したイベント型を使用して、オブジェクトにイベント ハンドラーを追加します。

addHandlerAsync(eventType: Office.EventType, handler: (result: any) => void, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult<void>) => void): void;

パラメーター

eventType
Office.EventType

追加するイベントの種類を指定します。 CustomXmlPart オブジェクトの場合、eventType パラメーターは、、Office.EventType.NodeInserted、および Office.EventType.NodeReplacedとしてOffice.EventType.NodeDeleted指定できます。

handler

(result: any) => void

追加するイベント ハンドラー関数。パラメーターの種類は Office.NodeDeletedEventArgsOffice.NodeInsertedEventArgs、または Office.NodeReplacedEventArgs です。

options
Office.AsyncContextOptions

コールバックで使用するために、任意の型のコンテキスト データを変更せずに保持するためのオプションを提供します。

callback

(result: Office.AsyncResult<void>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。

戻り値

void

注釈

要件セット: CustomXmlParts

各イベント ハンドラー関数の名前が一意である限り、指定した eventType に対して複数のイベント ハンドラーを追加できます。

addHandlerAsync(eventType, handler, callback)

指定したイベント型を使用して、オブジェクトにイベント ハンドラーを追加します。

addHandlerAsync(eventType: Office.EventType, handler: (result: any) => void, callback?: (result: AsyncResult<void>) => void): void;

パラメーター

eventType
Office.EventType

追加するイベントの種類を指定します。 CustomXmlPart オブジェクトの場合、eventType パラメーターは、、Office.EventType.NodeInserted、および Office.EventType.NodeReplacedとしてOffice.EventType.NodeDeleted指定できます。

handler

(result: any) => void

追加するイベント ハンドラー関数。パラメーターの種類は Office.NodeDeletedEventArgsOffice.NodeInsertedEventArgs、または Office.NodeReplacedEventArgs です。

callback

(result: Office.AsyncResult<void>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。

戻り値

void

注釈

要件セット: CustomXmlParts

各イベント ハンドラー関数の名前が一意である限り、指定した eventType に対して複数のイベント ハンドラーを追加できます。

// To add an event handler for the NodeDeleted event, use the addHandlerAsync method of the CustomXmlPart object.
function addNodeDeletedEvent() {
    Office.context.document.customXmlParts.getByIdAsync(
        "{3BC85265-09D6-4205-B665-8EB239A8B9A1}", function (result) {
        const xmlPart = result.value;
        xmlPart.addHandlerAsync(Office.EventType.NodeDeleted, function (eventArgs) {
            write("A node has been deleted.");
        });
    });
}
// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message;
}
// To add an event handler for the NodeInserted event, use the addHandlerAsync method of the CustomXmlPart object.
function addNodeInsertedEvent() {
    Office.context.document.customXmlParts.getByIdAsync(
        "{3BC85265-09D6-4205-B665-8EB239A8B9A1}", function (result) {
        const xmlPart = result.value;
        xmlPart.addHandlerAsync(Office.EventType.NodeInserted, function (eventArgs) {
            write("A node has been inserted.");
        });
    });
}
// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message;
}
// To add an event handler for the NodeReplaced event, use the addHandlerAsync method of the CustomXmlPart object.
function addNodeReplacedEvent() {
    Office.context.document.customXmlParts.getByIdAsync(
        "{3BC85265-09D6-4205-B665-8EB239A8B9A1}", function (result) {
        const xmlPart = result.value;
        xmlPart.addHandlerAsync(Office.EventType.NodeReplaced, function (eventArgs) {
            write("A node has been replaced.");
        });
    });
}
// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message;
}

deleteAsync(options, callback)

カスタム XML パーツを削除します。

deleteAsync(options?: Office.AsyncContextOptions, callback?: (result: AsyncResult<void>) => void): void;

パラメーター

options
Office.AsyncContextOptions

コールバックで使用するために、任意の型のコンテキスト データを変更せずに保持するためのオプションを提供します。

callback

(result: Office.AsyncResult<void>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。

戻り値

void

注釈

要件セット: CustomXmlParts

deleteAsync(callback)

カスタム XML パーツを削除します。

deleteAsync(callback?: (result: AsyncResult<void>) => void): void;

パラメーター

callback

(result: Office.AsyncResult<void>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。

戻り値

void

注釈

要件セット: CustomXmlParts

function deleteXMLPart() {
    Office.context.document.customXmlParts.getByIdAsync(
        "{3BC85265-09D6-4205-B665-8EB239A8B9A1}", function (result) {
        const xmlPart = result.value;
        xmlPart.deleteAsync(function (eventArgs) {
            write("The XML Part has been deleted.");
        });
    });
}
// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

getNodesAsync(xPath, options, callback)

指定された XPath に一致するこのカスタム XML パーツ内の CustomXmlNodes を非同期に取得します。

getNodesAsync(xPath: string, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult<CustomXmlNode[]>) => void): void;

パラメーター

xPath

string

取得するノードを指定する XPath 式。 必須です。

options
Office.AsyncContextOptions

コールバックで使用するために、任意の型のコンテキスト データを変更せずに保持するためのオプションを提供します。

callback

(result: Office.AsyncResult<Office.CustomXmlNode[]>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。 結果のプロパティは value 、xPath パラメーターに渡される XPath 式で指定されたノードを表す CustomXmlNode オブジェクトの配列です。

戻り値

void

注釈

要件セット: CustomXmlParts

getNodesAsync(xPath, callback)

指定された XPath に一致するこのカスタム XML パーツ内の CustomXmlNodes を非同期に取得します。

getNodesAsync(xPath: string, callback?: (result: AsyncResult<CustomXmlNode[]>) => void): void;

パラメーター

xPath

string

取得するノードを指定する XPath 式。 必須です。

callback

(result: Office.AsyncResult<Office.CustomXmlNode[]>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。 結果のプロパティは value 、xPath パラメーターに渡される XPath 式で指定されたノードを表す CustomXmlNode オブジェクトの配列です。

戻り値

void

注釈

要件セット: CustomXmlParts

function showXmlNodeType() {
    Office.context.document.customXmlParts.getByIdAsync(
        "{3BC85265-09D6-4205-B665-8EB239A8B9A1}", function (result) {
        const xmlPart = result.value;
        xmlPart.getNodesAsync('*/*', function (nodeResults) {
            for (let i = 0; i < nodeResults.value.length; i++) {
                const node = nodeResults.value[i];
                write(node.nodeType);
            }
        });
    });
}
// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

getXmlAsync(options, callback)

このカスタム XML パーツ内の XML を非同期的に取得します。

getXmlAsync(options?: Office.AsyncContextOptions, callback?: (result: AsyncResult<string>) => void): void;

パラメーター

options
Office.AsyncContextOptions

コールバックで使用するために、任意の型のコンテキスト データを変更せずに保持するためのオプションを提供します。

callback

(result: Office.AsyncResult<string>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。 結果のプロパティは value 、参照される CustomXmlPart オブジェクトの XML を含む文字列です。

戻り値

void

注釈

要件セット: CustomXmlParts

getXmlAsync(callback)

このカスタム XML パーツ内の XML を非同期的に取得します。

getXmlAsync(callback?: (result: AsyncResult<string>) => void): void;

パラメーター

callback

(result: Office.AsyncResult<string>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。 結果のプロパティは value 、参照される CustomXmlPart オブジェクトの XML を含む文字列です。

戻り値

void

注釈

要件セット: CustomXmlParts

function showXMLPartInnerXML() {
    Office.context.document.customXmlParts.getByIdAsync(
        "{3BC85265-09D6-4205-B665-8EB239A8B9A1}", function (result) {
        const xmlPart = result.value;
        xmlPart.getXmlAsync(function (eventArgs) {
            write(eventArgs.value);
        });
    });
}
// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

removeHandlerAsync(eventType, handler, options, callback)

指定したイベントの種類のイベント ハンドラーを削除します。

removeHandlerAsync(eventType: Office.EventType, handler?: (result: any) => void, options?: RemoveHandlerOptions, callback?: (result: AsyncResult<void>) => void): void;

パラメーター

eventType
Office.EventType

削除するイベントの型を指定します。 CustomXmlPart オブジェクトの場合、eventType パラメーターは、、Office.EventType.NodeInserted、および Office.EventType.NodeReplacedとしてOffice.EventType.NodeDeleted指定できます。

handler

(result: any) => void

削除するハンドラーの名前。

options
Office.RemoveHandlerOptions

削除されるイベント ハンドラーまたはハンドラーを決定するオプションを提供します。

callback

(result: Office.AsyncResult<void>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。

戻り値

void

注釈

要件セット: CustomXmlParts

removeHandlerAsync(eventType, handler, callback)

指定したイベントの種類のイベント ハンドラーを削除します。

removeHandlerAsync(eventType: Office.EventType, handler?: (result: any) => void, callback?: (result: AsyncResult<void>) => void): void;

パラメーター

eventType
Office.EventType

削除するイベントの型を指定します。 CustomXmlPart オブジェクトの場合、eventType パラメーターは、、Office.EventType.NodeInserted、および Office.EventType.NodeReplacedとしてOffice.EventType.NodeDeleted指定できます。

handler

(result: any) => void

削除するハンドラーの名前。

callback

(result: Office.AsyncResult<void>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。

戻り値

void

注釈

要件セット: CustomXmlParts

function removeNodeInsertedEventHandler() {
    Office.context.document.customXmlParts.getByIdAsync(
        "{3BC85265-09D6-4205-B665-8EB239A8B9A1}",
        function (result) {
            const xmlPart = result.value;
            xmlPart.removeHandlerAsync(Office.EventType.DataNodeInserted, {handler:myHandler});
    });
}