【发布时间】:2014-03-10 16:23:21
【问题描述】:
我有一个问题,我想从一个 XML 中获取一个属性,并为另一个 XML 使用相同的获取值。听起来很容易,但我需要解决一件事。我的第一个 XML 如下所示:
<?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>
在那里我获取nb_frames 属性并将其保存在一个名为$totalframes 的参数中:
$xmlpfad = [xml](Get-Content C:\Users\Administrator\Desktop\input_dcp\$filename+totalframes.xml)
[string]$totalframes = $xmlpfad.ffprobe.streams.stream | select nb_frames
现在,当我尝试将此值用于我的第二个 XML 时,我会得到如下信息:
<NumOfRepetitions>@{nb_frames=1152}</NumOfRepetitions>
但我只需要值 1152 本身,没有@{nb_frames=} 这是否可能以某种方式?
【问题讨论】:
标签: xml powershell formatting