Shell命令用于将xml文件中的值提取到Shell脚本中

时间:2017-07-17 17:17:52

标签: xml shell xpath xmllint

我有以下xml文本

# Batch normalization of the raw input
tf_b_VCCs_AMs_BN1 = tf.layers.batch_normalization(
    tf_b_VCCs_AMs, # the input vector, size [#batches, #time_steps, 2]
    axis=-1, # axis that should be normalized 
    training=Flg_training, # Flg_training = True during training, and False during test
    trainable=True,
    name="Inputs_BN"
    )

# Bidirectional dynamic stacked LSTM

##### The part I changed in the new model (start) #####
dropcells = []
for iiLyr in range(3):
    cell_iiLyr = tf.nn.rnn_cell.LSTMCell(num_units=250, state_is_tuple=True)
    dropcells.append(tf.nn.rnn_cell.DropoutWrapper(cell=cell_iiLyr, output_keep_prob=0.5))
##### The part I changed in the new model (end) #####

MultiLyr_cell = tf.nn.rnn_cell.MultiRNNCell(cells=dropcells, state_is_tuple=True)

outputs, states  = tf.nn.bidirectional_dynamic_rnn(
    cell_fw=MultiLyr_cell, 
    cell_bw=MultiLyr_cell,
    dtype=tf.float32,
    sequence_length=tf_b_lens, # the actual lengths of the input sequences (tf_b_VCCs_AMs_BN1)
    inputs=tf_b_VCCs_AMs_BN1,
    scope = "BiLSTM"
    )

我有一个shell脚本,需要来自此文件的build_id,(build_id不断更改)。如何提取" build_id"该文件中的值为该脚本中的变量。

1 个答案:

答案 0 :(得分:0)

xmlstarlet对于查询XML文件非常有用

示例:

xmlstarlet sel -t -m 'buildinfo' sample.xml

Output: 
buildinfo 
buildinfo/build 
buildinfo/build/analysis_unit

更多信息:http://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.html