Click here to Skip to main content
15,918,211 members
Home / Discussions / C#
   

C#

 
GeneralRe: Incorrect syntax near keyword 'DEFAULT' Pin
Dave Kreskowiak25-Feb-05 13:08
mveDave Kreskowiak25-Feb-05 13:08 
GeneralRe: Incorrect syntax near keyword 'DEFAULT' Pin
Mark T Garcia25-Feb-05 13:30
Mark T Garcia25-Feb-05 13:30 
GeneralWindows Form and Message Box Pin
MarkMokris25-Feb-05 7:51
MarkMokris25-Feb-05 7:51 
GeneralRe: Windows Form and Message Box Pin
Peter Nirschl25-Feb-05 9:31
Peter Nirschl25-Feb-05 9:31 
GeneralRe: Windows Form and Message Box Pin
DougW4825-Feb-05 14:04
DougW4825-Feb-05 14:04 
GeneralRe: Windows Form and Message Box Pin
leppie25-Feb-05 19:24
leppie25-Feb-05 19:24 
GeneralXmlValidingReader getting started Pin
Kenny O'Dell25-Feb-05 7:50
Kenny O'Dell25-Feb-05 7:50 
GeneralRe: XmlValidingReader getting started Pin
Kenny O'Dell25-Feb-05 7:53
Kenny O'Dell25-Feb-05 7:53 
Sorry, didn't realize is was going to strip out the XML stuff. I'll try again.

I am trying to write then read my first XML file. It is meant to store settings for a device. The user will store stuff to the file, then maybe load it back and transmit it to the target board. Sounds pretty simple.

My question is how to parse this guy. How do I get the data back out so I can plop it on the forms I've created? I see how to rifle through the file, but now how the heck to see where I am. I'm very new to this, so a real-world example would be great.

Here's how I'm setting up to do the read.

StreamReader stream = new StreamReader(fi.FullName);
XmlTextReader reader = new XmlTextReader(stream);
XmlSchemaCollection schemaColl = new XmlSchemaCollection();
schemaColl.Add(null,"XMLSchema_LCData.xsd");
XmlValidatingReader valReader = new XmlValidatingReader(reader);
valReader.ValidationType = ValidationType.Schema;
valReader.Schemas.Add(schemaColl);
valReader.ValidationEventHandler += new ValidationEventHandler(valHandler);

while (valReader.Read())
{
// Now what? How would I know that I have some certain piece of data?
// Pretend I want to know that is the FINV0 for CreepB from the XML file.
}



Here's the XML file I am trying to parse:

<?xml version="1.0"?>
<XMLSchema_LCData xmlns="http://tempuri.org/XMLSchema_LCData.xsd">
<DateSaved>2/25/2005 1:51:54 PM</DateSaved>
<SoftwareName>X-RES</SoftwareName>
<SoftwarePartNumber> 172814r</SoftwarePartNumber>
<SoftwareVersion>0.1.0</SoftwareVersion>
<SerialNumber>someCell</SerialNumber>
<PartNumber>somenumber</PartNumber>
<AD_Configuration>
<RoughCal>40.591</RoughCal>
<TempGain>11.95457</TempGain>
<TempOffset>-884002</TempOffset>
<TempOffset>16</TempOffset>
<InputQR>40</InputQR>
<OutputDecimator>1</OutputDecimator>
<TemperatureDecimator>8</TemperatureDecimator>
<TemperatureQR>10</TemperatureQR>
</AD_Configuration>
<AD_Runtime>
<RetrainThreshold>120</RetrainThreshold>
<HysteresisThreshold>60</HysteresisThreshold>
<NoiseRequirement>4</NoiseRequirement>
<OpenLoopQR>255</OpenLoopQR>
<MaxQR>70</MaxQR>
<MinQR>20</MinQR>
</AD_Runtime>
<SystemTC>
<ZA>169666</ZA>
<ZB>0.01226807</ZB>
<ZC>-4.305039E-07</ZC>
<SB>4.582489E-08</SB>
<SC>-5.763168E-13</SC>
</SystemTC>
<Linearity>
<Cor>1.255103E-10</Cor>
<Gain>0.9998779</Gain>
</Linearity>
<Creep>
<CreepA>
<FinV0>6.496906E-05</FinV0>
<FinV1>0</FinV1>
<FinV2>0</FinV2>
<Tau0>0.001777649</Tau0>
<Tau1>0</Tau1>
<Tau2>0</Tau2>
</CreepA>
<CreepB>
<FinV0>4.994869E-05</FinV0>
<FinV1>0</FinV1>
<FinV2>0</FinV2>
<Tau0>0.0001777411</Tau0>
<Tau1>0</Tau1>
<Tau2>0</Tau2>
</CreepB>
<CreepC>
<FinV0>9.953976E-06</FinV0>
<FinV1>0</FinV1>
<FinV2>0</FinV2>
<Tau0>5.924702E-05</Tau0>
<Tau1>0</Tau1>
<Tau2>0</Tau2>
</CreepC>
</Creep>
<Hysteresis>
<Zero>119020</Zero>
<Span>968630</Span>
<GuardBand>200</GuardBand>
<Increasing>
<A_Term>0</A_Term>
<B_Term>0</B_Term>
<C_Term>0</C_Term>
<E_Term>-1.065821E-12</E_Term>
</Increasing>
<Increasing>
<A_Term>8E-05</A_Term>
<B_Term>-8.259087E-11</B_Term>
<C_Term>0</C_Term>
<E_Term>-1.065821E-12</E_Term>
</Increasing>
</Hysteresis>
</XMLSchema_LCData>

Any help?

Kenny O'Dell
Sr. R&D Software Engineer
Mettler-Toledo Inc.
Inman, SC
GeneralRe: XmlValidingReader getting started Pin
Radgar25-Feb-05 8:10
Radgar25-Feb-05 8:10 
GeneralTextBox context menu Pin
MitchellBaldwin25-Feb-05 7:43
MitchellBaldwin25-Feb-05 7:43 
GeneralRe: TextBox context menu Pin
Radgar25-Feb-05 7:50
Radgar25-Feb-05 7:50 
GeneralRe: TextBox context menu Pin
MitchellBaldwin25-Feb-05 8:57
MitchellBaldwin25-Feb-05 8:57 
GeneralUNKNOWN PROBLEM (ListBox DataSource ) Pin
Radgar25-Feb-05 7:31
Radgar25-Feb-05 7:31 
GeneralRe: ListBox DataSource PROBLEM Pin
Dave Kreskowiak25-Feb-05 7:55
mveDave Kreskowiak25-Feb-05 7:55 
GeneralRe: ListBox DataSource PROBLEM Pin
Radgar25-Feb-05 8:12
Radgar25-Feb-05 8:12 
GeneralRedirectFromLogin Page help Pin
cmitty25-Feb-05 5:55
cmitty25-Feb-05 5:55 
GeneralRe: RedirectFromLogin Page help Pin
Heath Stewart25-Feb-05 6:29
protectorHeath Stewart25-Feb-05 6:29 
GeneralRe: RedirectFromLogin Page help Pin
GaMBiT_KC26-Feb-05 1:07
GaMBiT_KC26-Feb-05 1:07 
GeneralRe: RedirectFromLogin Page help Pin
Anonymous27-Feb-05 22:27
Anonymous27-Feb-05 22:27 
Generalrun desktop application on webpage Pin
Member 148149125-Feb-05 5:06
Member 148149125-Feb-05 5:06 
GeneralRe: run desktop application on webpage Pin
Heath Stewart25-Feb-05 5:22
protectorHeath Stewart25-Feb-05 5:22 
GeneralMessageBox shows no text Pin
Sailer0125-Feb-05 5:01
sussSailer0125-Feb-05 5:01 
GeneralRe: MessageBox shows no text Pin
Heath Stewart25-Feb-05 6:40
protectorHeath Stewart25-Feb-05 6:40 
GeneralRe: MessageBox shows no text Pin
GaMBiT_KC26-Feb-05 1:00
GaMBiT_KC26-Feb-05 1:00 
GeneralC# and Custom C++ interfaces Pin
vad_kr25-Feb-05 3:40
vad_kr25-Feb-05 3:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.