本文介绍了使用 XML starlet 拉取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定:

 <UOIS UOI_ID="9352923211a63c6fe6643832d3c4a7786e21ed26" CONTENT_TYPE="VIDEO" NAME="TR2014_295_11_1a_PM.mov" VERSION="1" METADATA_STATE_DT="2016-06-03 17:01:10.0" METADATA_STATE_USER_ID="1" IMPORT_DT="2016-06-03 13:35:58.0" IMPORT_USER_ID="1" MASTER_OBJ_MIME_TYPE="video/quicktime" MODEL_ID="30001">
 <FILE_SIZE_VIEW CONTENT_SIZE="100948.92       " />
 <SI_AV_ASSET_METADATA VIDEO_BIT_RATE="226 Mbps" REGIONAL_ENCODING_FORMAT="NTSC" DC_TITLE="TR2014_295_11_1a_PM.mov" VIDEO_ORIGINATION_FORMAT="Betacam SP" AV_ASSET_TYPE="Video - Original" MODIFICATION="Editing Allowed" />
 <SI_AUDIO_LANGUAGE_DTLS LANGUAGE="English" />
 <SI_ASSET_METADATA HOT_FOLDER_IMPORT_ID="23335" PUBLIC_USE="No" PRIMARY_CREATOR="Bl" CAPTURE_DEVICE="Captured via Sony DVW-A500 Digital Betacam VTR, SDI to Blackmagic UltraStudio Express ADC to Blackmagic Media Express software" IS_RESTRICTED="No" OWNING_UNIT_UNIQUE_NAME="NMAAHC-TR2014_295_11_1a_PM" ALTERNATE_IDENTIFIER_1="TR2014.295" COLOR_SPACE="YCbCr " EMBARGO="No" />
 </UOIS>

如何提取 UOI_IDOWNING_UNIT_UNIQUE_NAME 的值?如何从不同的标签中提取属性并将它们连接起来是基本问题.

How do I pull the values for UOI_ID and OWNING_UNIT_UNIQUE_NAME?How to pull attributes from different tags and concat them is the basic question.

推荐答案

假设 SI_ASSET_METADATAUOIS 的直接孩子(目前不清楚,因为 UOIS 元素未关闭):

Assuming that SI_ASSET_METADATA is direct child of UOIS (currently, it isn't clear since UOIS element isn't closed) :

xmlstarlet sel -t -m "//UOIS" \
        -v "concat(@UOI_ID, ', ' , SI_ASSET_METADATA/@OWNING_UNIT_UNIQUE_NAME)" \
        -n your_xml.xml

这篇关于使用 XML starlet 拉取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 22:12