DeveloperBarn Forums

Go Back   DeveloperBarn Forums > Programming & Scripting > Visual Basic Programming

Discuss "XML Node Error" in the Visual Basic Programming forum.

Visual Basic Programming - Learn coding practices and tips to get the best out of your Visual Basic applications. Visual Basic was developed by Microsoft for building stand alone Windows based applications.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old June 3rd, 2008, 07:30 AM
Moderator

 
Join Date: Apr 2008
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 1
noFriends is an unknown quantity at this point

Awards Showcase
Classic ASP 
Total Awards: 1

Default 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.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old June 3rd, 2008, 07:53 AM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 530
Thanks: 14
Thanked 38 Times in 37 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead is on a distinguished road

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

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
Did I help you out? Make me popular by clicking the icon!

If you found a post helpful, please click the button in the lower right-hand corner of the post.

Powered by ASP.Net
Reply With Quote
  #3 (permalink)  
Old June 3rd, 2008, 08:00 AM
Moderator

 
Join Date: Apr 2008
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 1
noFriends is an unknown quantity at this point

Awards Showcase
Classic ASP 
Total Awards: 1

Default

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
Reply With Quote
  #4 (permalink)  
Old June 3rd, 2008, 08:25 AM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 530
Thanks: 14
Thanked 38 Times in 37 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead is on a distinguished road

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

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

Comments on this post
noFriends agrees: fanks!
Reply With Quote
The Following User Says Thank You to jmurrayhead For This Useful Post:
noFriends (June 3rd, 2008)
  #5 (permalink)  
Old June 3rd, 2008, 08:57 AM
Moderator

 
Join Date: Apr 2008
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 1
noFriends is an unknown quantity at this point

Awards Showcase
Classic ASP 
Total Awards: 1

Default

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 With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > Visual Basic Programming

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wizard1 error The command 'MoveComplete' is not valid peebman2000 .Net Development 10 April 28th, 2008 02:52 PM
[Error] Microsoft JET Database Engine error '80004005' Operation must use an updatea theChris ASP Development 2 March 16th, 2008 10:18 AM


Sponsored Links

ASP.NET Resource Index
a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer.

Free Web Directory
Including Chats and Forums Resources, Offer automatic, instant and free directory submissions.
URLZ Web Directory
URLZ Web Directory

Free Web Directory - Add Your Link
The Little Web Directory
Free Web Directory
Pegasus free web directory is a free directory organised by categories.

Web Directory & SEO Services
dirroot web directory


All times are GMT -4. The time now is 07:38 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 2008 DeveloperBarn.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46