hi everyone... i'm a newbie to xpath and i don't know how to extract all the ToolAlarm nodes from my xml file...

here's the xml file and code snippet:

<?xml version="1.0" encoding="utf-8" ?>
<ToolConfigurations>
<ToolType name ="EQP1">
<ToolAlarms>
<ToolAlarm name = "AIR PRESSURE LOW"/>
<ToolAlarm name = "FALSE ALARM"/>
<ToolAlarm name = "NO INCOMING POWER SUPPLY"/>
<ToolAlarm name = "SERVO ERROR"/>
<ToolAlarm name = "OTHERS"/>
</ToolAlarms>
</ToolType>
</ToolConfigurations>

string fileName = "ToolConfigurations.xml";
XPathDocument xPathDoc = new XPathDocument(fileName);
XPathNavigator xPathNav = xPathDoc.CreateNavigator();
XPathExpression xPathExpr;
xPathExpr = xPathNav.Compile("//EquipmentType[@name='DA']/Defects/*");
XPathNodeIterator xPathIterator = xPathNav.Select(xPathExpr);

i tried different xpath expressions to no avail..

can somebody please help?

thanks..
lupin

hi everyone... i'm a newbie to xpath and i don't know how to extract all the ToolAlarm nodes from my xml file...

here's the xml file and code snippet:

<?xml version="1.0" encoding="utf-8" ?>
<ToolConfigurations>
<ToolType name ="EQP1">
<ToolAlarms>
<ToolAlarm name = "AIR PRESSURE LOW"/>
<ToolAlarm name = "FALSE ALARM"/>
<ToolAlarm name = "NO INCOMING POWER SUPPLY"/>
<ToolAlarm name = "SERVO ERROR"/>
<ToolAlarm name = "OTHERS"/>
</ToolAlarms>
</ToolType>
</ToolConfigurations>

string fileName = "ToolConfigurations.xml";
XPathDocument xPathDoc = new XPathDocument(fileName);
XPathNavigator xPathNav = xPathDoc.CreateNavigator();
XPathExpression xPathExpr;
xPathExpr = xPathNav.Compile("//EquipmentType[@name='DA']/Defects/*");
XPathNodeIterator xPathIterator = xPathNav.Select(xPathExpr);

i tried different xpath expressions to no avail..

can somebody please help?

thanks..
lupin

Corrections:
xPathExpr should be:

xPathExpr = xPathNav.Compile("//ToolType[@name='EQP1']/ToolAlarm /*");

sorry for the confusion...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.