Javascript 仅使用某些子节点访问xml中父节点的子节点
由于我正在开发一个产品软件,我需要您的帮助来解决我的问题 我有一组字符串格式的变量中的XML数据 任务是查找父节点,该父节点具有名为“PropertyReference”的子节点。XML的结构如下所示 如果该解决方案可以使用jquery语法解决,那么它将非常棒Javascript 仅使用某些子节点访问xml中父节点的子节点,javascript,jquery,xml,xml-parsing,Javascript,Jquery,Xml,Xml Parsing,由于我正在开发一个产品软件,我需要您的帮助来解决我的问题 我有一组字符串格式的变量中的XML数据 任务是查找父节点,该父节点具有名为“PropertyReference”的子节点。XML的结构如下所示 如果该解决方案可以使用jquery语法解决,那么它将非常棒 <StringAttribute Caption="comments" ColumnName="fccomments" Description="comments" MaxLength="54" Name="fccomments"
<StringAttribute Caption="comments" ColumnName="fccomments" Description="comments" MaxLength="54" Name="fccomments" />
<StringAttribute Caption="department" ColumnName="fdept" Description="department" MaxLength="2" Name="fdept">
<PropertyReference Name="inwork_fdept" ObjectName="Department" PropertyName="fdeptno" UseIndexView="True" />
</StringAttribute>
<DecimalAttribute Caption="labor cost/hour" ColumnName="flabcost" ContentType="Price" DecimalDigits="2" Description="labor cost/hour" MaxValue="999.99" MinValue="-99.99" Name="flabcost">
<DecimalAttribute.Format>
<DecimalFormat DecimalDigits="2" Name="Price" />
</DecimalAttribute.Format>
</DecimalAttribute>
<DecimalAttribute Caption="Avg Queue Hours" ColumnName="fnavgque" DecimalDigits="1" Description="average queue time - generated by scheduling" MaxValue="99999.9" MinValue="-999.9" Name="fnavgque" />
<BooleanAttribute Caption="Default Operations for this Work Center to be Scheduled" ColumnName="flschedule" Description="schedule?" Name="flschedule" />
<BooleanAttribute Name="flscheduleEnable">
<BooleanAttribute.Triggers>
<Trigger InverseOperation="True" Operator="Equals" Value="True">
<Rule Target="flschedule" Type="ReadOnly" Value="OnClient" />
</Trigger>
</BooleanAttribute.Triggers>
</BooleanAttribute>
<IntegerAttribute Caption="Max Simultaneous Operations/Shift 1" ColumnName="fnmax1" DefaultValue="1" Description="maximum simmultaneous ops shift 1" MaxValue="99" MinValueAdherenceMessage="MAX_SIMUL_OPS" Name="fnmax1" />
<IntegerAttribute Caption="Max Simultaneous Operations/Shift 2" ColumnName="fnmax2" Description="maximum simmultaneous ops shift 2" MaxValue="99" MinValueAdherenceMessage="MAX_SIMUL_OPS" Name="fnmax2" />
提前谢谢你。也许有点像这样:
var parentNode = $(yourXMLStringHere).find("PropertyReference").parent();
演示:$('PropertyReference').parent()代码>
例如:
console.log($('PropertyReference').parent().length);
$('PropertyReference').parent().each(function() {
console.log($(this).attr('Caption'));
});
那么,哪些可能的位置可以作为PropertyReference???