I understand I am not altering original XML. What I want is reduce it on a filter but preserve all the nested structure.
On Thu, Apr 21, 2016 at 2:17 PM Harbs <harbs.li...@gmail.com> wrote: > You are not losing the hierarchy. XMLList is simply a list of the XML > elements (kind of like an array). The original XML is not altered. You can > walk the elements and find their parents and children. > > If you need new XML with only certain elements, you need to construct it > (or destruct it) yourself. > > On Apr 21, 2016, at 9:53 PM, mark goldin <markzolo...@gmail.com> wrote: > > > I have the following XML: > > <Asset name="Asset 1"> > > <Project Name="Health Score - T1 - 5" TemplateID="8" TemplateName="Asset > > Health Template 1" Score="0.98" Hex="0x008000" Color="Green" XAxisScore=" > > 0.98" YAxisScore="5.00"> > > <Point InputPointID="363" Name="COSINE" Reading="0.31" > OutputPointID="343" > > Score="1.00" Hex="0xFFFF00" Color="Yellow"/> > > <Point InputPointID="367" Name="SINE" Reading="0.95" OutputPointID="347" > > Score="3.00" Hex="0xFF0000" Color="Red"/> > > </Project> > > <Project ID="36" Name="Health Score - T3 - 41" AssetID="110" > TemplateID="20" > > TemplateName="Asset Health Template 3" Score="2.00" Hex="0xFFA500" > Color=" > > Orange" XAxisScore="2.00" YAxisScore="41.00"> > > <Point InputPointID="1242" Name="LAG" Reading="1.00" OutputPointID="1266" > > Score="3.00" Hex="0xFF0000" Color="Red"/> > > <Point InputPointID="1246" Name="LEAD" Reading="0.00" > OutputPointID="1262" > > Score="0.00" Hex="0x008000" Color="Green"/> > > <Point InputPointID="1230" Name="1TO5" Reading="4.00" > OutputPointID="1258" > > Score="3.00" Hex="0xFF0000" Color="Red"/> > > </Project> > > <Project ID="43" Name="Health Score - T4 - 64" AssetID="110" > TemplateID="21" > > TemplateName="Asset Health Template 4" Score="0.35" Hex="0x008000" > Color=" > > Green" XAxisScore="0.35" YAxisScore="64.00"> > > <Point InputPointID="1689" Name="COSINE" Reading="-0.43" > OutputPointID="1713 > > " Score="0.00" Hex="0x008000" Color="Green"/> > > <Point InputPointID="1709" Name="SINE" Reading="-0.90" > OutputPointID="1717" > > Score="0.00" Hex="0x008000" Color="Green"/> > > <Point InputPointID="1697" Name="LAG" Reading="1.00" OutputPointID="1729" > > Score="3.00" Hex="0xFF0000" Color="Red"/> > > <Point InputPointID="1701" Name="LEAD" Reading="0.00" > OutputPointID="1733" > > Score="0.00" Hex="0x008000" Color="Green"/> > > </Project> > > </Asset> > > > > If I filter it like this: > > XML..Project.(@TemplateID == 8); > > I get: > > <Project Name="Health Score - T1 - 5" TemplateID="8" TemplateName="Asset > > Health Template 1" Score="0.98" Hex="0x008000" Color="Green" XAxisScore=" > > 0.98" YAxisScore="5.00"> > > <Point InputPointID="363" Name="COSINE" Reading="0.31" > OutputPointID="343" > > Score="1.00" Hex="0xFFFF00" Color="Yellow"/> > > <Point InputPointID="367" Name="SINE" Reading="0.95" OutputPointID="347" > > Score="3.00" Hex="0xFF0000" Color="Red"/> > > </Project> > > > > which is correct but I am losing the hierarchy. > > > > What I expect is: > > <Asset name="Asset 1"> > > <Project Name="Health Score - T1 - 5" TemplateID="8" TemplateName="Asset > > Health Template 1" Score="0.98" Hex="0x008000" Color="Green" XAxisScore=" > > 0.98" YAxisScore="5.00"> > > <Point InputPointID="363" Name="COSINE" Reading="0.31" > OutputPointID="343" > > Score="1.00" Hex="0xFFFF00" Color="Yellow"/> > > <Point InputPointID="367" Name="SINE" Reading="0.95" OutputPointID="347" > > Score="3.00" Hex="0xFF0000" Color="Red"/> > > </Project> > > </Asset> > > > > Any idea how to do that? > > > > Thanks > >