Skip to content

Instantly share code, notes, and snippets.

@taisyo7333
Last active September 2, 2015 08:39
Show Gist options
  • Save taisyo7333/77770fd81da4ece469f2 to your computer and use it in GitHub Desktop.
Save taisyo7333/77770fd81da4ece469f2 to your computer and use it in GitHub Desktop.
Get a value of attribute by C# LINQ to XML .
XElement po = XElement.Load(path_xml);
// <Substrates>
// <Substrate SubstrateType = "Strip" SubstrateId = "@@@">
var elems = po.Elements().Descendants()
.Where(node => node.Name.LocalName == "Substrate"
&& (string)node.Attribute("SubstrateType") == "Strip"
&& node.Attribute("SubstrateId") != null
)
.Select(elem => elem.Attribute("SubstrateId").Value);
foreach (var el in elems)
{
// write out @@@
Trace.WriteLine(el.ToString());
}
<?xml version="1.0" encoding="utf-8"?>
<MapData xmlns="urn:semi-org:xsd.E142-1.V1005.SubstrateMap">
<Layouts>
<Layout LayoutId="WaferLayout_abcxyz" DefaultUnits="mm" TopLevel="true">
<Dimension X="1" Y="4" />
<ChildLayouts>
<ChildLayout LayoutId="DeviceLayout_abcxyz" />
</ChildLayouts>
</Layout>
<Layout LayoutId="DeviceLayout_abcxyz" DefaultUnits="mm">
<Dimension X="1" Y="600" />
</Layout>
</Layouts>
<Substrates>
<Substrate SubstrateType="Strip" SubstrateId="MyStripID" />
</Substrates>
<SubstrateMaps>
<SubstrateMap SubstrateType="Strip" SubstrateId="MyStripID"
LayoutSpecifier="WaferLayout_abcxyz/DeviceLayout_abcxyz"
Orientation="0"
OriginLocation="LowerRight"
AxisDirection="UpLeft">
</SubstrateMap>
</SubstrateMaps>
</MapData>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment