簡體   English   中英

訪問父節點的子節點的XML與某些子節點只

[英]accessing child node of parent nodes in xml with certain child nodes only

由於我正在開發產品軟件,因此需要您的幫助以解決問題。

我在字符串格式的變量中有一組XML數據。

任務是找到具有稱為“ PropertyReference”的子節點的父節點。 XML的結構如下所示。

如果解決方案可以使用jquery語法解決,那就太好了...

<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();

演示: http//jsfiddle.net/yHXK5/

$('PropertyReference').parent();

例如:

console.log($('PropertyReference').parent().length);

$('PropertyReference').parent().each(function() {
    console.log($(this).attr('Caption'));
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM