こんにちは、同じ要素がネストされたxmlがあります。再帰的です(うれしい!)
そのようです:
<MyRoot>
<Record Name="Header" >
<Field Type="Pattern" Expression=";VR_PANEL_ID,\s+" />
<Field Name="PanelID" Type="Pattern" Expression="\d+"/>
<Field Type="Pattern" Expression="," />
<Field Name="ProductionDateTime" Type="Pattern" Expression=".+?(?=,)" />
<Field Type="Pattern" Expression=".+?" />
</Record>
<Record Name="Body" MaxOccurs="0">
<Record Name="Command" Compositor="Choice">
<Record Name="Liquid Status" >
<Record Name="Header" >
<Field Type="Pattern" Expression="i30100" />
<Field Name="DateTime" Type="Pattern" Expression="\d{10}"/>
</Record>
<Record Name="Data" MinOccurs="0" MaxOccurs="0">
<Field Name="DeviceNum" Type="Pattern" Expression="\d\d" />
<Field Name="Status" Type="Pattern" Expression="\d{4}" />
</Record>
</Record>
</Record>
<Record Name="Footer" >
<Field Type="Pattern" Expression="&&[A-F0-9]" />
</Record>
</Record>
</MyRoot>
XmlReader
が の上に配置されたら、(この場合はand )MyRoot
の直接の子のみをループする方法はありますか。これらのノードの xml の読み取りを別のクラスに再帰的に委譲しています。MyRoot
<Record Name="Header" >
<Record Name="Body" MaxOccurs="0">
重複した質問を検討する前に、OP が の xpath 軸以外の孫やその他のノードセットについて尋ねていないことを確認してchildren
ください。私はこの質問に完全に一致するものを見つけることができませんでしXmlReader
た.
私がやりたいのは、 を引き渡しXmlReader
、子 xml を消費している子オブジェクトが次の子を取得するために必要な場所を指し示すようにすることです。それは甘いでしょう。