N
NachoShaw
Guest
Hi
To further my XML quandry, i have a new problem that i am trying to resolve and struggling to do.
In my XML (example below), there are multiple Elements named standardComponentData. I am reading through the XML document and for each Element, the function is looping through the nodes and returning each node.Name & node.InnerText into a DataTable. This works ok. My problem is that 1 level above each found Element, there is additional data that i also need to include in the return function. Problem is, not all found Elements of standardComponentData are at the same level in the XML. See this xml same of code i copied out.
<ellipsoidalHead>
<standardComponentData>
<!-- Standard Component Data -->
<identifier>RIGHT HEAD</identifier>
<idNumber>1576685225</idNumber>
<attachedTo>Undefined</attachedTo>
</standardComponentData>
<straightFlangeLength units="in">2.0000</straightFlangeLength>
<straightFlangeNominalThickness units="in">0.3750</straightFlangeNominalThickness>
<straightFlangeInnerDiameter units="in">23.2500</straightFlangeInnerDiameter>
<straightFlangeOuterDiameter units="in">24.0000</straightFlangeOuterDiameter>
<straightFlangeStaticHeadOperating units="psi">0.8483</straightFlangeStaticHeadOperating>
<straightFlangeStaticHeadOperatingPlusDesignP units="psi">150.8483</straightFlangeStaticHeadOperatingPlusDesignP>
<ellipsoidalHeadRatio2>2</ellipsoidalHeadRatio2>
<ellipsoidalHeadRatio>2:1</ellipsoidalHeadRatio>
</ellipsoidalHead>
<nozzle>
<standardComponentData>
<!-- Standard Component Data -->
<identifier>UPPER LT CONNECTION (H1)</identifier>
<idNumber>1576739035</idNumber>
<attachedTo>RIGHT HEAD</attachedTo>
</standardComponentData>
<!-- Nozzle Specific Data -->
<nozzleType>1</nozzleType>
<nozzleTypeDescription>Type 1 - No pad, no internal projection, UW-16.1(c), (d) or (e)</nozzleTypeDescription>
<nozzleStyle>0</nozzleStyle>
<nozzleStyleDescription>Uniform Thickness</nozzleStyleDescription>
<nozzleFlange>
<standardComponentData>
<!-- Standard Component Data -->
<identifier>ASME B16.5/16.47 flange attached to UPPER LT CONNECTION (H1)</identifier>
<idNumber>1579536826</idNumber>
<attachedTo>UPPER LT CONNECTION (H1)</attachedTo>
</standardComponentData>
<!-- Flange Specific Data -->
<flangeCode>ASME B16.5</flangeCode>
<flangeType>Welding Neck</flangeType>
<flangeClass>Class 150</flangeClass>
</nozzleFlange>
</nozzle>
in this example, i need to return the additional data of ellipsoidalHead, nozzle, nozzleFlange but only the Element directly related to the current standardComponentData Element, not any of the other esame named Elements further down the XML.
To complicate things further, at least for me, some of the Elements like nozzle, have data outside of the standardComponentData Element but then, another sub level Element contained within the nozzle Element which i do not need to return. Hopefully my explanation is ok so far..
Is there a way to search between Elements (without naming the Elements because they appear randomly)? for example:
I would iterate through standardComponentData nodes, step up 1 level to nozzle, iterate the nozzle nodes (excluding standardComponentData) and then stop at nozzleFlange
My current code works ok with ellipsoidalHead but for nozzle, gives me all of the nodes including all for any sub level Element which is incorrect.
Thanks
Nacho is the derivative of Nigel - True fact! I am self taught in VB.Net. 50% of the time, I am right 100% of the time!
Continue reading...
To further my XML quandry, i have a new problem that i am trying to resolve and struggling to do.
In my XML (example below), there are multiple Elements named standardComponentData. I am reading through the XML document and for each Element, the function is looping through the nodes and returning each node.Name & node.InnerText into a DataTable. This works ok. My problem is that 1 level above each found Element, there is additional data that i also need to include in the return function. Problem is, not all found Elements of standardComponentData are at the same level in the XML. See this xml same of code i copied out.
<ellipsoidalHead>
<standardComponentData>
<!-- Standard Component Data -->
<identifier>RIGHT HEAD</identifier>
<idNumber>1576685225</idNumber>
<attachedTo>Undefined</attachedTo>
</standardComponentData>
<straightFlangeLength units="in">2.0000</straightFlangeLength>
<straightFlangeNominalThickness units="in">0.3750</straightFlangeNominalThickness>
<straightFlangeInnerDiameter units="in">23.2500</straightFlangeInnerDiameter>
<straightFlangeOuterDiameter units="in">24.0000</straightFlangeOuterDiameter>
<straightFlangeStaticHeadOperating units="psi">0.8483</straightFlangeStaticHeadOperating>
<straightFlangeStaticHeadOperatingPlusDesignP units="psi">150.8483</straightFlangeStaticHeadOperatingPlusDesignP>
<ellipsoidalHeadRatio2>2</ellipsoidalHeadRatio2>
<ellipsoidalHeadRatio>2:1</ellipsoidalHeadRatio>
</ellipsoidalHead>
<nozzle>
<standardComponentData>
<!-- Standard Component Data -->
<identifier>UPPER LT CONNECTION (H1)</identifier>
<idNumber>1576739035</idNumber>
<attachedTo>RIGHT HEAD</attachedTo>
</standardComponentData>
<!-- Nozzle Specific Data -->
<nozzleType>1</nozzleType>
<nozzleTypeDescription>Type 1 - No pad, no internal projection, UW-16.1(c), (d) or (e)</nozzleTypeDescription>
<nozzleStyle>0</nozzleStyle>
<nozzleStyleDescription>Uniform Thickness</nozzleStyleDescription>
<nozzleFlange>
<standardComponentData>
<!-- Standard Component Data -->
<identifier>ASME B16.5/16.47 flange attached to UPPER LT CONNECTION (H1)</identifier>
<idNumber>1579536826</idNumber>
<attachedTo>UPPER LT CONNECTION (H1)</attachedTo>
</standardComponentData>
<!-- Flange Specific Data -->
<flangeCode>ASME B16.5</flangeCode>
<flangeType>Welding Neck</flangeType>
<flangeClass>Class 150</flangeClass>
</nozzleFlange>
</nozzle>
in this example, i need to return the additional data of ellipsoidalHead, nozzle, nozzleFlange but only the Element directly related to the current standardComponentData Element, not any of the other esame named Elements further down the XML.
To complicate things further, at least for me, some of the Elements like nozzle, have data outside of the standardComponentData Element but then, another sub level Element contained within the nozzle Element which i do not need to return. Hopefully my explanation is ok so far..
Is there a way to search between Elements (without naming the Elements because they appear randomly)? for example:
I would iterate through standardComponentData nodes, step up 1 level to nozzle, iterate the nozzle nodes (excluding standardComponentData) and then stop at nozzleFlange
My current code works ok with ellipsoidalHead but for nozzle, gives me all of the nodes including all for any sub level Element which is incorrect.
Thanks
Nacho is the derivative of Nigel - True fact! I am self taught in VB.Net. 50% of the time, I am right 100% of the time!
Continue reading...