Camelへのご質問、ご相談、お申し込みは以下フォームよりお問い合わせください。

Camel導入についてのご相談や
無料デモのお申し込み・
資料請求について
お気軽にお問い合わせください。

// 対象のXPath文字列 const xpath = '/html/body/header/div/nav/div[1]/div'; // document.evaluate() を利用してXPathに一致する最初のノードを取得 const result = document.evaluate( xpath, // XPath式 document, // 検索開始ノード(ここではdocument全体) null, // ネームスペースリゾルバ(不要な場合はnull) XPathResult.FIRST_ORDERED_NODE_TYPE, // 結果のタイプ指定 null // 以前の結果(使わないのでnull) ); // 取得したノードを変数に格納 const targetElement = result.singleNodeValue; if (targetElement) { // 挿入するHTML文字列(ここでは「お問い合わせ」ボタンの例) const htmlToInsert = ` お問い合わせ2 `; // 対象要素の末尾にHTMLを挿入 targetElement.insertAdjacentHTML('beforeend', htmlToInsert); } else { console.error("指定されたXPathに一致する要素が見つかりませんでした。"); }