problem accessing with DTD data in xml

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zmerzed
    New Member
    • Oct 2012
    • 1

    problem accessing with DTD data in xml

    I am having a problem accessing with DTD data in xml.
    Code:
    Imports System
    Imports System.Xml
    
    
    Module Module1
    
        Sub Main()
       
            Using reader As XmlReader = XmlReader.Create("00000002.xml")
                While reader.Read()
                    ' Check for start elements.
                    If reader.IsStartElement() Then
    
                        ' See if perls element or article element.
                        If reader.Name = "result" Then
                            Console.WriteLine("Start <result> element.")
    
                        ElseIf reader.Name = "sample" Then
                            Console.WriteLine("Start <sample> element.")
                            ' Get name attribute.
                            Dim attribute As String = reader("samplenumber")
                            If attribute IsNot Nothing Then
                                Console.WriteLine("  Has attribute name: {0}", attribute)
                            End If
    
                            ' Text data.
                            If reader.Read() Then
                                Console.WriteLine("  Text node: {0}", reader.Value.Trim())
                            End If
                        End If
    
                    End If
                End While
            End Using
          
        End Sub
    End Module
    in xml file

    Code:
    <?xml version="1.0" standalone="no"?>
    <!DOCTYPE result SYSTEM "result.dtd">
    <result>
    <sample sampleid="1" samplenumber="RLG 512" applname="Starter" n_constituent="12">
    <datestart year="2012" month="6" date="19" hour="7" minute="27" second="2"/>
    <datestop year="2012" month="6" date="19" hour="7" minute="27" second="32"/>
    <constituent id="1" name="Brix" value="     14.04" GH="      1.69" NH="      1.09"/>
    <constituent id="2" name="Pol" value="     10.15" GH="      1.69" NH="      1.09"/>
    <constituent id="19" name="Trash" value="     28.66" GH="      0.00" NH="6182057154624353400000000000000000.00"/>
    <constituent id="20" name="Fibre" value="      9.52" GH="      1.69" NH="      1.09"/>
    <constituent id="21" name="Ash" value="     -0.63" GH="      1.69" NH="      1.09"/>
    <constituent id="22" name="DryMatter" value="     21.60" GH="      1.69" NH="      1.09"/>
    <constituent id="24" name="Glucose" value="      1.13" GH="      1.69" NH="      1.09"/>
    <constituent id="25" name="Fructose" value="      1.42" GH="      1.69" NH="      1.09"/>
    <constituent id="26" name="PIC" value="      8.68" GH="      0.00" NH="      0.00"/>
    <constituent id="27" name="BIC" value="     12.28" GH="      0.00" NH="      0.00"/>
    <constituent id="31" name="TRS" value="     11.69" GH="      0.00" NH="509313097534660010000000000000000.00"/>
    <constituent id="32" name="Purity" value="     72.31" GH="      0.00" NH="      0.00"/>
    </sample>
    </result>
    Last edited by Frinavale; Oct 29 '12, 03:26 PM. Reason: Added text that describes the problem in the title to the body of the thread.
  • Meetee
    Recognized Expert Contributor
    • Dec 2006
    • 928

    #2
    Where's the question?. Explain your code and problem.

    Comment

    Working...