I will review the informatin and advise. Thank you.
Main Topics
Browse All TopicsMy experience with XML is limited. I am trying to extract data from the sampling of the below XML file at end. The data use to be in a text file that was imported into Excel and processed via macros. I need to get the XML data into the same spreadsheet format to continue using the extensive programming within the Excel file.
Using the XMLTextReader, I am able to see the data, but I am trying to execute specific code based on the various elements. Example, the values of the SummaryValueData will be written in a specific area of an Excel Spreadsheet. The values of the DailyTestSummaryData will be written to another location as will the DailyCalibrationData values within the DailyTestSummaryData. The same will be true for the HourlyOperatingData. I am looking specifically for VB.Net coding (I am using 2003) to extract the data based on the major elements. Using the Excel XML features do not accomplish what I need, hence the VB.NET approach.
================CODE SNIPPET
Sub emXml()
'this section will process the EM xml file
'strFileName is a global variable
MsgBox("emXml : " & strFileName)
Dim strTemp As String
'Declare and Load file
Dim xmlDoc As New XmlDocument
Dim xNode As XmlNode
xmlDoc.Load(strFileName)
Dim reader As XmlTextReader = New XmlTextReader(strFileName)
Do While (reader.Read())
Select Case reader.NodeType
Case XmlNodeType.Element 'Display beginning of element.
strTemp = (reader.Name)
If reader.HasAttributes Then 'If attributes exist
While reader.MoveToNextAttribute
'Display attribute name and value.
strTemp = strTemp & (" {0}='{1}'" & reader.Name & reader.Value)
End While
End If
strTemp = strTemp
If strTemp = "SummaryValueData" Then
'this returns an integer...not what I wanted
MsgBox(XmlNodeType.Text & " " & reader.Value)
End If
If strTemp = "DailyTestSummaryData" Then
'this returns an integer...not what I wanted
MsgBox("DTSD " & XmlNodeType.Text & " " & reader.Value)
End If
Case XmlNodeType.Text 'Display the text in each element.
'this displays all of my values
lblFileName.Text = strTemp & ": " & reader.Value()
lblFileName.Refresh()
Dim x As Integer
For x = 1 To 100000000
'for next set just to allow the lblFileName.text
'to be read-not to be left as permanent part
'of program
Next
Select Case strTemp
'this is looking at various element names and gives appropriate value except it
'never hits the SummaryValueData Case
Case "ORISCode"
MsgBox("ORis is " & reader.Value)
Case "Year"
MsgBox("Year is " & reader.Value)
Case "SummaryValueData"
MsgBox("SummaryValueData is " & reader.Value)
End Select
End Select
Loop
'Call UpdateExcel()
End Sub
''''''''''XML FILE SAMPLING''''''''''''''''''
<?xml version="1.0" encoding="utf-8"?>
<Emissions>
<ORISCode>1234</ORISCode>
<Year>2007</Year>
<Quarter>1</Quarter>
<SubmissionComment/>
<Version>1.2</Version>
<SummaryValueData>
<UnitID>001</UnitID>
<ParameterCode>CO2M</Param
<CurrentReportingPeriodTot
<OzoneSeasonToDateTotal/>
<YearToDateTotal>238270.80
</SummaryValueData>
<DailyTestSummaryData>
<UnitID>001</UnitID>
<Date>2009-01-01</Date>
<Hour>7</Hour>
<Minute>24</Minute>
<MonitoringSystemID/>
<ComponentID>013</Componen
<TestTypeCode>DAYCAL</Test
<TestResultCode>PASSED</Te
<SpanScaleCode/>
<DailyCalibrationData>
<OnLineOffLineIndicator>1<
<UpscaleGasCode>HIGH</Upsc
<ZeroInjectionDate>2009-01
<ZeroInjectionHour>7</Zero
<ZeroInjectionMinute>22</Z
<UpscaleInjectionDate>2009
<UpscaleInjectionHour>7</U
<UpscaleInjectionMinute>24
<ZeroMeasuredValue>0.000</
<UpscaleMeasuredValue>2.60
<ZeroAPSIndicator>0</ZeroA
<UpscaleAPSIndicator>0</Up
<ZeroCalibrationError>0.00
<UpscaleCalibrationError>2
<ZeroReferenceValue>0.000<
<UpscaleReferenceValue>2.5
</DailyCalibrationData>
</DailyTestSummaryData>
<DailyTestSummaryData>
<UnitID>001</UnitID>
<Date>2009-01-01</Date>
<Hour>7</Hour>
<Minute>25</Minute>
<MonitoringSystemID/>
<ComponentID>013</Componen
<TestTypeCode>INTCHK</Test
<TestResultCode>PASSED</Te
<SpanScaleCode/>
</DailyTestSummaryData>
<HourlyOperatingData>
<UnitID>001</UnitID>
<Date>2009-03-20</Date>
<Hour>15</Hour>
<OperatingTime>1.00</Opera
<HourLoad>90</HourLoad>
<LoadUnitsOfMeasureCode>MW
<LoadRange>9</LoadRange>
<CommonStackLoadRange/>
<FcFactor>1840.0</FcFactor
<FdFactor/>
<FwFactor/>
<FuelCode/>
<MonitorHourlyValueData>
<ParameterCode>CO2C</Param
<UnadjustedHourlyValue>12.
<AdjustedHourlyValue/>
<MODCCode>01</MODCCode>
<MonitoringSystemID>104</M
<ComponentID>014</Componen
<PercentAvailable>86.8</Pe
<MoistureBasis/>
</MonitorHourlyValueData>
<MonitorHourlyValueData>
<ParameterCode>FLOW</Param
<UnadjustedHourlyValue>151
<AdjustedHourlyValue>15420
<MODCCode>01</MODCCode>
<MonitoringSystemID>103</M
<ComponentID>013</Componen
<PercentAvailable>99.9</Pe
<MoistureBasis/>
</MonitorHourlyValueData>
<MonitorHourlyValueData>
<ParameterCode>NOXC</Param
<UnadjustedHourlyValue>107
<AdjustedHourlyValue/>
<MODCCode>01</MODCCode>
<MonitoringSystemID/>
<ComponentID>015</Componen
<PercentAvailable/>
<MoistureBasis/>
</MonitorHourlyValueData>
<MonitorHourlyValueData>
<ParameterCode>SO2C</Param
<UnadjustedHourlyValue>51.
<AdjustedHourlyValue>51.80
<MODCCode>01</MODCCode>
<MonitoringSystemID>102</M
<ComponentID>012</Componen
<PercentAvailable>86.8</Pe
<MoistureBasis/>
</MonitorHourlyValueData>
<DerivedHourlyValueData>
<ParameterCode>CO2</Parame
<UnadjustedHourlyValue/>
<AdjustedHourlyValue>111.6
<MODCCode/>
<MonitoringSystemID/>
<FormulaIdentifier>401</Fo
<PercentAvailable/>
<OperatingConditionCode/>
<SegmentNumber/>
<FuelCode/>
</DerivedHourlyValueData>
<DerivedHourlyValueData>
<ParameterCode>HI</Paramet
<UnadjustedHourlyValue/>
<AdjustedHourlyValue>1064.
<MODCCode/>
<MonitoringSystemID>104</M
<FormulaIdentifier>801</Fo
<PercentAvailable/>
<OperatingConditionCode/>
<SegmentNumber/>
<FuelCode/>
</DerivedHourlyValueData>
<DerivedHourlyValueData>
<ParameterCode>NOXR</Param
<UnadjustedHourlyValue>0.1
<AdjustedHourlyValue>0.187
<MODCCode>01</MODCCode>
<MonitoringSystemID>105</M
<FormulaIdentifier>501</Fo
<PercentAvailable>78.4</Pe
<OperatingConditionCode/>
<SegmentNumber/>
<FuelCode/>
</DerivedHourlyValueData>
<DerivedHourlyValueData>
<ParameterCode>SO2</Parame
<UnadjustedHourlyValue/>
<AdjustedHourlyValue>132.6
<MODCCode/>
<MonitoringSystemID/>
<FormulaIdentifier>201</Fo
<PercentAvailable/>
<OperatingConditionCode/>
<SegmentNumber/>
<FuelCode/>
</DerivedHourlyValueData>
</HourlyOperatingData>
<HourlyOperatingData>
<UnitID>001</UnitID>
<Date>2009-03-31</Date>
<Hour>23</Hour>
<OperatingTime>1.00</Opera
<HourLoad>89</HourLoad>
<LoadUnitsOfMeasureCode>MW
<LoadRange>9</LoadRange>
<CommonStackLoadRange/>
<FcFactor>1840.0</FcFactor
<FdFactor/>
<FwFactor/>
<FuelCode/>
<MonitorHourlyValueData>
<ParameterCode>NOXC</Param
<UnadjustedHourlyValue>108
<AdjustedHourlyValue/>
<MODCCode>01</MODCCode>
<MonitoringSystemID/>
<ComponentID>015</Componen
<PercentAvailable/>
<MoistureBasis/>
</MonitorHourlyValueData>
<MonitorHourlyValueData>
<ParameterCode>SO2C</Param
<UnadjustedHourlyValue>57.
<AdjustedHourlyValue>57.00
<MODCCode>01</MODCCode>
<MonitoringSystemID>102</M
<ComponentID>012</Componen
<PercentAvailable>86.8</Pe
<MoistureBasis/>
</MonitorHourlyValueData>
<DerivedHourlyValueData>
<ParameterCode>SO2</Parame
<UnadjustedHourlyValue/>
<AdjustedHourlyValue>144.2
<MODCCode/>
<MonitoringSystemID/>
<FormulaIdentifier>201</Fo
<PercentAvailable/>
<OperatingConditionCode/>
<SegmentNumber/>
<FuelCode/>
</DerivedHourlyValueData>
</HourlyOperatingData>
</Emissions>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I am unable to resolve the underlined code that was an example in the suggested link. I am not able to get the XmlReaderSettings in the VB.Net 2003. I have added the MSXML2 reference. Any suggestions.
Dim myXmlSettings As New XmlReaderSettings
Using readMovieInfo As XmlReader = XmlReader.Create("test.xml
While readMovieInfo.Read()
ShowXmlNode(readMovieInfo)
While readMovieInfo.MoveToNextAt
ShowXmlNode(readMovieInfo)
End While
End While
End Using
Business Accounts
Answer for Membership
by: aboredmanPosted on 2009-04-28 at 13:11:02ID: 24254728
take a look at this emample: http://www.java2s.com/Code /VB/XML/ Us eXMLReader todisplayX MLtagNodet ypeandattr ibutes.htm