parse_xml()

string XML 値として解釈し、値を JSON に変換し、値を として dynamic返します。

構文

parse_xml(parse_xml()

構文規則について詳しく知る。

パラメーター

名前 必須 説明
xml string ✔️ 解析する XML 形式の文字列値。

戻り値

xml の値によって決定される動的型のオブジェクト*。またはXML 形式が無効な*場合は null 値*。

変換は次のように行われます。

XML JSON Access
<e/> { "e": null } o.e
<e>text</e> { "e": "text" } o.e
<e name="value" /> { "e":{"@name": "value"} } o.e["@name"]
<e name="value">text</e> { "e": { "@name": "value", "#text": "text" } } o.e["@name"] o.e["#text"]
<e> <a>text</a> <b>text</b> </e> { "e": { "a": "text", "b": "text" } } o.e.a o.e.b
<e> <a>text</a> <a>text</a> </e> { "e": { "a": "text", "b": "text" } } o.e.a[0] o.e.a[1]
<e> text <a>text</a> </e> { "e": { "#text": "text", "a": "text" } } 1`o.e["#text"] o.e.a

Note

  • parse_xml最大入力string長は 1 MB (1,048,576 バイト) です。 文字列の解釈が長いほど、null オブジェクトになります。
  • 要素*ノード*、属性*、およびテキスト ノード*のみが移動*されます。 それ以外はすべてスキップされます。

次の例では、context_custom_metricsstring である場合、次のようになります。

<?xml version="1.0" encoding="UTF-8"?>
<duration>
    <value>118.0</value>
    <count>5.0</count>
    <min>100.0</min>
    <max>150.0</max>
    <stdDev>0.0</stdDev>
    <sampledValue>118.0</sampledValue>
    <sum>118.0</sum>
</duration>

次に CSL フラグメント*が、XML* を以下の JSON* に移動*します:

{
    "duration": {
        "value": 118.0,
        "count": 5.0,
        "min": 100.0,
        "max": 150.0,
        "stdDev": 0.0,
        "sampledValue": 118.0,
        "sum": 118.0
    }
}

その後、オブジェクト*の duration スロット*の値を取得し、そこから 2 つのスロット*duration.valueおよびduration.min (118.0100.0 それぞれ) を取得します。

T
| extend d=parse_xml(context_custom_metrics) 
| extend duration_value=d.duration.value, duration_min=d["duration"]["min"]