+ Reply to Thread
Results 1 to 5 of 5

Thread: XML Node Error

  1. #1
    Barn Frequenter noFriends is on a distinguished road noFriends's Avatar
    Join Date
    Apr 2008
    Posts
    179
    Rep Power
    4

    XML Node Error

    Hi everyone

    I need to read in an xml file and add it to the db, but for some reason, its not
    picking up the nodes, I might be overlooking something.
    the basic structure of the xml looks like this:
    Code:
    <?xml version = '1.0'?>
    <ROWSET>
       <ROW num="1">
          <ISBN_KEY>xxxx</ISBN_KEY>
          <ISBN>xxxx</ISBN>
          <EXTENT>xx</EXTENT>
          <ILLUSTRATIONSxxx</ILLUSTRATIONS>
          <TRIM_METRIC>xxxxx</TRIM_METRIC>
       </ROW>
       <ROW num="2">
          <ISBN_KEY>xxxx</ISBN_KEY>
          <ISBN>xxxx</ISBN>
          <EXTENT>xx</EXTENT>
          <ILLUSTRATIONSxxx</ILLUSTRATIONS>
          <TRIM_METRIC>xxxxx</TRIM_METRIC>
       </ROW>
       <ROW num="3">
          <ISBN_KEY>xxxx</ISBN_KEY>
          <ISBN>xxxx</ISBN>
          <EXTENT>xx</EXTENT>
          <ILLUSTRATIONSxxx</ILLUSTRATIONS>
          <TRIM_METRIC>xxxxx</TRIM_METRIC>
       </ROW>
    </ROWSET>
    
    and I am reading it with this, but its not showing me the msgbox?
    Code:
    	'--Create MSXML 4.0 DOM Object and initialize it
    	Set objXMLDOM = CreateObject("MSXML2.DOMDocument.4.0")
    	objXMLDOM.validateOnParse = False
    
    	'--Load the XML file
    	objXMLDOM.load "C:\Documents and Settings\Jako\Desktop\XML Process\export.xml"
    
    		Set objNodes = objXMLDOM.selectNodes("/ROWSET/ROW")
    
    		'--Add records
    		For Each objNodeItem In objNodes
    			msgbox objNodeItem.selectSingleNode("ISBN_KEY").nodeTypedValue
    			Write_RecordToDB objNodeItem, strCurFileName
    			
    		Next
    
    	Set objXMLDOM = Nothing
    
    I am using the exact same code for another xml file, but there the structure is a bit different, I think it might be the row num=x part that is causing the problems?

    Any ideas?
    Thanks.

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Is this Visual Basic or VbScript?

    Everything here seems to be right and I don't think the node attributes num="1", num="2", etc. would be having any effect on it.

    Maybe there is an error not being reported? Try this:

    Code:
    '--Create MSXML 4.0 DOM Object and initialize it
    Set objXMLDOM = CreateObject("MSXML2.DOMDocument.4.0")
    objXMLDOM.validateOnParse = False
     
     '--Load the XML file
     If objXMLDOM.load("C:\Documents and Settings\Jako\Desktop\XML Process\export.xml") Then
        Set objNodes = objXMLDOM.selectNodes("/ROWSET/ROW")
     
        '--Add records
        For Each objNodeItem In objNodes
            msgbox objNodeItem.selectSingleNode("ISBN_KEY").nodeTypedValue
            Write_RecordToDB objNodeItem, strCurFileName
        Next
    Else
        msgbox objXMLDOM.parseError.reason
    End If
     
    Set objXMLDOM = Nothing
    
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  3. #3
    Barn Frequenter noFriends is on a distinguished road noFriends's Avatar
    Join Date
    Apr 2008
    Posts
    179
    Rep Power
    4

    Hi J

    yeah, I had some error parsing code in, but I thought that if I left it out it should still
    process it? It has some invalid chars it seems, like:

    Timæus and Caraël
    but the later shouldn't make it crash?

    I am a real n00b with xml, please halp

  4. #4
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Those characters shouldn't be a problem. XML documents can contain non ASCII characters, like Norwegian æ ø å , or French ê è é.

    Take a look here as far as XML encoding errors are concerned: XML Encoding

    I made some changes here, see if this works:
    Code:
    '--Create MSXML 4.0 DOM Object and initialize it
    Set objXMLDOM = CreateObject("MSXML2.DOMDocument.4.0")
    objXMLDOM.validateOnParse = False
     
     '--Load the XML file
     If objXMLDOM.load("C:\Documents and Settings\Jako\Desktop\XML Process\export.xml") Then
        Set objNodes = objXMLDOM.documentElement.selectNodes("/ROWSET/ROW")
     
        '--Add records
        For Each objNodeItem In objNodes
            msgbox objNodeItem.selectSingleNode("ISBN_KEY").nodeTypedValue
            Write_RecordToDB objNodeItem, strCurFileName
        Next
    Else
        msgbox objXMLDOM.parseError.reason
    End If
     
    Set objXMLDOM = Nothing
    
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  5. #5
    Barn Frequenter noFriends is on a distinguished road noFriends's Avatar
    Join Date
    Apr 2008
    Posts
    179
    Rep Power
    4

    thanks J, seems it was an encoding issue, its parsing now, changed the format
    to UTF-16 and its reading it properly.

    thanks a mill!!!

+ Reply to Thread

Similar Threads

  1. Wizard1 error The command 'MoveComplete' is not valid
    By peebman2000 in forum .NET Development
    Replies: 10
    Last Post: April 28th, 2008, 03:52 PM
  2. Replies: 2
    Last Post: March 16th, 2008, 11:18 AM

Bookmarks

Posting Permissions

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

SEO by vBSEO