?
Solved

Why parse an XML file selectNodes doesnt work?

Posted on 2009-03-31
2
Medium Priority
?
788 Views
Last Modified: 2013-12-26
I'm using SelectNodes from XMLDocument (In access 2003) in order to read all of the Nodes contained in the file, but I'm having some problems to get the second and third nodes in a loop.

When using this vb code, I receive two records of the first node ("//body2")
And go on to the rest of the xml, how do I get the individual values?


The xml doc start like :  
 <?xml version="1.0" encoding="UTF-8" ?>
- <form1>
      &
      &
- <section2>
  <header2 xmlns:xfa="http://www...../schema/xfa-data/1.0/" xfa:dataNode="dataGroup" />
- <body2>
  <contactPhone>07493153</contactPhone>
  <nameOfSchool>Ffff SCHOOL</nameOfSchool>
  <position>PRINCIPAL</position>
  <type>1</type>
  <givenNames>LEISA</givenNames>
  <surname>NEATON</surname>
  <employeeNo>2145</employeeNo>
  <fullName>LEISA NEATON</fullName>
  <location>School based</location>
  </body2>
- <body2>
  <contactPhone>07493153</contactPhone>
  <nameOfSchool>Fasdf</nameOfSchool>
  <position>TEACHER</position>
  <type>1</type>
  <givenNames>Barak</givenNames>
  <surname>OBAMA</surname>
  <employeeNo>2189</employeeNo>
  <fullName>Barak OBAMA</fullName>
  <location>School based</location>
  </body2>
  <addBody2 xmlns:xfa="http://www...../schema/xfa-data/1.0/" xfa:dataNode="dataGroup" />
  <Validate2 xmlns:xfa="http://www..../schema/xfa-data/1.0/" xfa:dataNode="dataGroup" />
  </section2>

&
&


    For Each nodeR In xmlFile.selectNodes("//body2")
        rst.AddNew
        rst!fldAppID = AppID
        rst!fldsName = nodeR.selectSingleNode("//surname").Text
        rst!fldgNames = nodeR.selectSingleNode("//givenNames").Text
        rst!fldPosition = nodeR.selectSingleNode("//position").Text
        rst!fldEORC = nodeR.selectSingleNode("//type").Text
        rst!fldEmployeeID = nodeR.selectSingleNode("//employeeNo").Text
        rst!fldPh = nodeR.selectSingleNode("//contactPhone").Text
        rst!fldSchoolDepartm = nodeR.selectSingleNode("//nameOfSchool").Text
        rst.Update
    Next nodeR


...
 Dim nodeR As IXMLDOMNode
 
    For Each nodeR In xmlFile.selectNodes("//body2")
        rst.AddNew
        rst!fldAppID = AppID
        rst!fldsName = nodeR.selectSingleNode("//surname").Text
        rst!fldgNames = nodeR.selectSingleNode("//givenNames").Text
        rst!fldPosition = nodeR.selectSingleNode("//position").Text
        rst!fldEORC = nodeR.selectSingleNode("//type").Text
        rst!fldEmployeeID = nodeR.selectSingleNode("//employeeNo").Text
        rst!fldPh = nodeR.selectSingleNode("//contactPhone").Text
        rst!fldSchoolDepartm = nodeR.selectSingleNode("//nameOfSchool").Text
        rst.Update
    Next nodeR

Open in new window

0
Comment
Question by:smayshar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
sandeep_patel earned 1000 total points
ID: 24045289
please move this question in VB zone.

Regards,
Sandeep
0
 

Author Closing Comment

by:smayshar
ID: 31646743
not answeared
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question