Results 1 to 5 of 5

Thread: [RESOLVED] Parsing XML

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Resolved [RESOLVED] Parsing XML

    Hello, I'm trying to parse a XML file, but I have never done that before. I've looked at a whole bunch of examples, but I'm already stuck at the beginning.

    I need to have the following parts:
    On the 'file poster' line the filename "mts-mrb.rar" in the subject between """
    From each segment the segment bytes, segment number and the long string after the number (the number of segments are not always 10)

    Then the same with the next part, filename "mts-mrb.r00" on the next 'file poster' line, etc.

    Code:
    <?xml version="1.0" encoding="iso-8859-1" ?>
    <!DOCTYPE nzb PUBLIC "-//newzBin//DTD NZB 1.0//EN" "http://www.newzbin.com/DTD/nzb/nzb-1.0.dtd">
    <!-- NZB Generated by Binsearch.info -->
    <nzb xmlns="http://www.newzbin.com/DTD/2003/nzb">
    
    <file poster="[email protected] (YencL8 (Chil))" date="1175837221" subject="(Test Rar File)&quot;mts-mrb.rar&quot; yEnc (1/10)">
    <groups><group>alt.binaries.paxer</group></groups>
    <segments>
    <segment bytes="258743" number="1">[email protected]</segment>
    <segment bytes="258871" number="2">[email protected]</segment>
    <segment bytes="258724" number="3">[email protected]</segment>
    <segment bytes="258831" number="4">[email protected]</segment>
    <segment bytes="258642" number="5">[email protected]</segment>
    <segment bytes="258797" number="6">[email protected]</segment>
    <segment bytes="258783" number="7">[email protected]</segment>
    <segment bytes="258687" number="8">[email protected]</segment>
    <segment bytes="258790" number="9">[email protected]</segment>
    <segment bytes="25854" number="10">[email protected]</segment>
    </segments>
    </file>
    
    <file poster="[email protected] (YencL8 (Chil))" date="1175849534" subject="(Test Rar File)&quot;mts-mrb.r00&quot; yEnc (1/10)">
    <groups><group>alt.binaries.paxer</group></groups>
    <segments>
    <segment bytes="256615" number="1">[email protected]</segment>
    <segment bytes="256502" number="2">[email protected]</segment>
    <segment bytes="256237" number="3">[email protected]</segment>
    <segment bytes="256238" number="4">[email protected]</segment>
    <segment bytes="256139" number="5">[email protected]</segment>
    <segment bytes="256558" number="6">[email protected]</segment>
    <segment bytes="256618" number="7">[email protected]</segment>
    <segment bytes="256658" number="8">[email protected]</segment>
    <segment bytes="256713" number="9">[email protected]</segment>
    <segment bytes="25813" number="10">[email protected]</segment>
    </segments>
    </file>
    </nzb>
    I'm getting an "Expected token 'EOF' found 'NAME'" error.
    Can anyone please tell me how to start with this? Thank you.

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.     Dim oxmlNodeList As IXMLDOMNodeList
    4.     Dim XMLDoc As MSXML2.DOMDocument40
    5.    
    6.     Set XMLDoc = New DOMDocument40
    7.     XMLDoc.async = False
    8.     XMLDoc.validateOnParse = False
    9.     XMLDoc.preserveWhiteSpace = False
    10.    
    11.     XMLDoc.Load "C:\1175965453.xml"
    12.    
    13.     If XMLDoc.parseError.errorCode = 0 Then
    14.         If XMLDoc.readyState = 4 Then
    15.             DoEvents
    16.         End If
    17.     Else
    18.         Err.Description = XMLDoc.parseError.reason & vbCrLf & _
    19.         "Line: " & XMLDoc.parseError.Line & vbCrLf & _
    20.         "XML: " & XMLDoc.parseError.srcText
    21.         Err.Raise 1006
    22.     End If
    23.    
    24.  
    25.     Set oxmlNodeList = XMLDoc.documentElement.selectNodes("/nzb xmlns")
    26.    
    27.  
    28.     Set XMLDoc = Nothing
    29.     Set oxmlNodeList = Nothing
    30. End Sub
    Last edited by Chris001; Sep 12th, 2010 at 12:40 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width