问题
Given:
<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>
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.
回答1:
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
来源:https://stackoverflow.com/questions/43216296/using-xml-starlet-to-pull-values