C#: Read XML Attribute

hockey_goalie31

New Member
Using C#2.0 and VIsualStudio2005I'm trying to access the "DisplayName" inside "MonitorResponseRecord"from an XML file like the one Below:\[code\] <Magellan xsi:schemaLocation="http://tempuri.org/XMLSchema.xsd ..\Schema\Configuration.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/XMLSchema.xsd"> <SchemaVersion>1.0</SchemaVersion> <MonitorScope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" id="CleanStationChemicalManifoldFeed5" xmlns="http://tempuri.org/XMLSchema.xsd"> <PersonalSafety> <MonitorResponseRecord Enabled="true" DisplayName="ChemicalManifoldFeed5ControllerFault"> <ExpressionMonitor> <Expression>(ChemicalManifold.Feed5.DispenseValve = Open) and ((ChemicalManifold.Feed5.ViolatedRegion = HighProcess) or (ChemicalManifold.Feed5.ViolatedRegion = LowProcess) or (ChemicalManifold.Feed5.ViolatedRegion = Minimum))</Expression> <TestInterval>0.1</TestInterval> <MinimumTimeBetweenResponses>5</MinimumTimeBetweenResponses> </ExpressionMonitor> <Response> <PostAlarm> <AlarmName>ChemicalManifold_Feed5_ControllerFault</AlarmName> <Parameter1 /> <Parameter2>Alarm Region = {ChemicalManifold.Feed5.ViolatedRegion}</Parameter2> <Parameter3>{RecipeName}-{StepName}</Parameter3> <Parameter4>FlowSetpoint = {ChemicalManifold.Feed5.Setpoint}-LPM, ActualFlow = {ChemicalManifold.Feed5.FlowMeter}-LPM</Parameter4> </PostAlarm> <ResponseEvent> <TargetResource /> <Event>PA</Event> <Reason>ChemicalSupply</Reason> </ResponseEvent> </Response> </MonitorResponseRecord> </PersonalSafety> <PersonalSafety> <MonitorResponseRecord Enabled="true" DisplayName = "PressureValveFailure"> ... ... ...and soon\[/code\]My current C# attempt is as follows, BUT it always hangs up when I try to \[code\]XmlDocument.Load("");\[/code\]\[code\] XmlDocument doc = new XmlDocument(); doc.Load("../UMC0009.Configuration.Root.xml"); string attrVal = doc.SelectSingleNode("MonitorResponseRecord/@DisplayName").Value;\[/code\]BUUUUT won't work :/ any help out there?UPDATE:the exception I recieve is as follows, and occures at the doc.Load("...") line: \[code\]{"Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function."} System.Exception {System.Xml.XPath.XPathException}\[/code\]
 
Back
Top