Fetching an attribute value from xml and reuse it for another xml in powershell? -


i have question, want fetch attribute 1 xml , use same fetched value xml. sounds pretty easy there 1 thing need around. first xml looks here:

<?xml version="1.0" encoding="utf-8"?> <ffprobe> <streams>     <stream index="0" codec_name="prores" codec_long_name="prores" codec_type="video" codec_time_base="1/24" codec_tag_string="apcs" codec_tag="0x73637061" width="1920" height="1080" has_b_frames="0" sample_aspect_ratio="0:1" display_aspect_ratio="0:1" pix_fmt="yuv422p10le" level="-99" r_frame_rate="24/1" avg_frame_rate="24/1" time_base="1/24" start_pts="0" start_time="0.000000" duration_ts="1152" duration="48.000000" bit_rate="13174677" nb_frames="1152" nb_read_frames="1152">         <disposition default="1" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0"/>         <tag key="creation_time" value="2013-10-10 02:59:14"/>         <tag key="language" value="eng"/>         <tag key="handler_name" value="datahandler"/>     </stream> </streams> </ffprobe> 

there grab nb_frames attribut , save in parameter called $totalframes :

$xmlpfad = [xml](get-content c:\users\administrator\desktop\input_dcp\$filename+totalframes.xml)         [string]$totalframes = $xmlpfad.ffprobe.streams.stream | select nb_frames 

now when try use value second xml like:

<numofrepetitions>@{nb_frames=1152}</numofrepetitions>

but need value 1152 itself, without @{nb_frames=} possible in kind of way?

your totalframes variable object has property called nb_frames.

in order value of property, need use -expandproperty parameter select cmdlet. change last line to:

[string]$totalframes = $xmlpfad.ffprobe.streams.stream | select -expandproperty nb_frames 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -