?
Solved

populating a node list

Posted on 2006-06-27
5
Medium Priority
?
226 Views
Last Modified: 2008-02-01
Help Please.
Hello XML'ers
I am pulling my hair out trying to figure out how to populate a NodeList object with all the YEARS from this following xml document.
I will pass the sFile variable to the object
I want all the "Survey year" nodes from the Structure Name

This is the VBA routine that i have.  I am already loaded the XML file
    Dim oYearNodeList As MSXML2.IXMLDOMNodeList
    Dim sfile As String 'FileSystemObject
   
    myXML.validateOnParse = False
   
    sfile = ActiveDesignFile.Name
    Set myXElem = myXML.documentElement


   
    On Error GoTo BADTHINGS
    Set oYearNodeList = myXML.selectNodes("Bridge_Scour/Structure[@Name='" & sfile & "']/Surveys[@year= " * "]
 
   
   
    Debug.Print "how"
BADTHINGS:
    MsgBox Error
End Sub



<?xml version="1.0"?>
<!DOCTYPE Bridge_Scour SYSTEM "Bridge_Scour.dtd">
<Bridge_Scour>
     <Structure Name = "uw1.dgn">
          <Surveys year="2000">
                <Survey>
                    <Entry><Station>0</Station> <Elevation>926.7</Elevation></Entry>
                    <Entry><Station>17</Station> <Elevation>925.1</Elevation></Entry>
          <Entry><Station>32</Station> <Elevation>922.7</Elevation></Entry>
                    <Entry><Station>47</Station> <Elevation>916.7</Elevation></Entry>
                    <Entry><Station>62</Station> <Elevation>911.6</Elevation></Entry>
                    <Entry><Station>100</Station> <Elevation>909.8</Elevation></Entry>
                </Survey>
          </Surveys>
          <Surveys year="2001">
                <Survey>
                    <Entry><Station>0.3</Station> <Elevation>123.47</Elevation></Entry>
                    <Entry><Station>0.4</Station> <Elevation>123.48</Elevation></Entry>
               </Survey>
          </Surveys>
     </Structure>
     <Structure Name = "uw2.dgn">
          <Surveys year="2001">
                <Survey>
                    <Entry><Station>0.5</Station> <Elevation>123.49</Elevation></Entry>
                    <Entry><Station>0.6</Station> <Elevation>123.50</Elevation></Entry>
               </Survey>
          </Surveys>
     </Structure>
</Bridge_Scour>


PLEASE HELP..

Thanks so much
If i could give a thousand points i would.

0
Comment
Question by:sherrick123
[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
5 Comments
 
LVL 14

Accepted Solution

by:
Pierre Cornelius earned 1000 total points
ID: 16992594
0
 

Author Comment

by:sherrick123
ID: 16992701
I have been able to get all the years BUT i want just the years for a certain structure WITHOUT going through a looping routine.  Their will be lots of years and i am concerned with processing time
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 1000 total points
ID: 16993633
Set oYearNodeList = myXML.selectNodes("Bridge_Scour/Structure[@Name='" & sfile & "']/Surveys/@year")
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 16993804
Hi sherrick123,
> Set oYearNodeList = myXML.selectNodes("Bridge_Scour/Structure[@Name='"
> & sfile & "']/Surveys[@year= " * "]

since we don't sem to get there the preceding-sibling way...

you can't use the '*' as a wildcard in XPath
just leaving that part out will give you all the surveys/@year

Set oYearNodeList = myXML.selectNodes("Bridge_Scour/Structure[@Name='" & sfile & "']/Surveys/@year")

will give you a list of years, not necessarily unique
you can then create an array of unique values from this nodeset
by looping over the nodeset and creatin a new item on the other array, if the value does not yet exist

I am still wondering why we can't get the preceding-sibling to work though...

Cheers!
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 16993815
sherrick123,

oh man I am late....
ignore my previous message
(and after that this one as well :-)
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

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

764 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