UiPath Documentation
activities
latest
false
重要 :
このコンテンツの一部は機械翻訳によって処理されており、完全な翻訳を保証するものではありません。 新しいコンテンツの翻訳は、およそ 1 ~ 2 週間で公開されます。
UiPath logo, featuring letters U and I in white

開発者向けのアクティビティ

最終更新日時 2026年4月21日

XML ファイルを読み取り逆シリアル化する

The following example explains how to use activities such as Deserialize XML, Execute XPath, Get XML Nodes, or Get XML Node Attributes for reading, deserializing, accessing, and displaying various information about an XML file. You can find these activities in the UiPath.WebAPI.Activities package.

注:

この例で説明するプロジェクトを含むアーカイブをダウンロードして展開し、daily_usd.xml ファイルをプロジェクト フォルダーにコピーしてください。

サンプルと同等のオートメーション プロセスは以下のように構築できます。

  1. Studio を開いて、新しいプロセスを作成します。
  2. デザイナー パネルに [シーケンス] コンテナーをドラッグします。
    • 次の変数を作成します。

      変数名変数の型既定値
      xml文字列
      xmlDeserializedXDocument
      xml_xpath_resultオブジェクト
      xmlNodesIEnumerable
      xmlAttributesIEnumerable
      allExchRates文字列
  3. シーケンス内に [テキスト ファイルを読み込み] アクティビティをドラッグします。
    • [FileName] フィールドに式 "daily_usd.xml" を追加します。
    • [プロパティ] パネルの [コンテンツ] フィールドに変数 xml を追加します。
  4. Add a Deserialize XML activity after the Read Text File activity.
    • [XML 文字列] フィールドに変数 xml を追加します。
    • [プロパティ] パネルの [XML ドキュメント] フィールドに変数 xmlDeserialized を追加します。
  5. Add an Execute XPath activity after the Deserialize XML activity.
    • [既存の XML] フィールドに値 xmlDeserialized を追加します。
    • "string(/channel/lastBuildDate)"[XPath 式] フィールドに追加します。
    • [プロパティ] パネルの [結果] フィールドに変数 xml_xpath_result を追加します。
  6. Add a Message Box activity after the Execute XPath activity.
    • [テキスト] フィールドに "Exchange rates for " + xml_xpath_result.ToString を追加します。
  7. Add a Get XML Nodes activity after the Message Box activity.
    • [既存の XML] フィールドに変数 xmlDeserialized を追加します。
    • [プロパティ] パネルの [XML ノード] フィールドに変数 xmlNodes を追加します。
  8. Add a Get XML Node Attributes activity after the Get XML Nodes activity.
    • [既存の XML ノード] フィールドに値 xmlNodes(0) を追加します。
    • [プロパティ] パネルの [属性] フィールドに変数 xmlAttributes を追加します。
  9. Add a Message Box activity after the Get XML Node Attributes activity.
    • [テキスト] フィールドに xmlAttributes(0).Name.Tostring + ": " + xmlAttributes(0).Value.Tostring を追加します。
  10. Add an Assign activity after the Message Box activity.
    • [左辺値 (To)/宛先] フィールドに変数 allExchRates を追加します。
    • [右辺値 (Value)] フィールドに式 "Exhange Rates" + System.Environment.NewLine を追加します。
  11. Add a For Each activity after the Assign activity.
    • xmlDeserialized.Element("channel").Elements("item")Value (値) フィールドに追加します。
    • [プロパティ] パネルの [TypeArgument (引数の型)] ドロップダウン リストから [System.Xml.Linq.XElement] を選択します。
  12. [繰り返し (コレクションの各要素)] アクティビティの [シーケンス] コンテナーに [代入] アクティビティを配置します。
    • [左辺値 (To)/宛先] フィールドに変数 allExchRates を追加します。
    • Add the following expression in the Value field: `allExchRates + System.Environment.NewLine + "1 " + item.Element("baseName").Value.ToString + " = " + item.Element("exchangeRate").Value.ToString
      • " " + item.Element("targetName").Value.ToString`.
  13. Add a Message Box activity after the For Each activity.
    • [テキスト] フィールドに変数 allExchRates を追加します。

      ドキュメントの画像

  14. プロセスを実行します。XML ファイルの読み取り、逆シリアル化、アクセスが実行されます。ファイルから抽出された情報を含むいくつかのメッセージ ボックスが表示されます。

こちらから サンプルをダウンロードできます。

このページは役に立ちましたか?

接続

ヘルプ リソース サポート

学習する UiPath アカデミー

質問する UiPath フォーラム

最新情報を取得