Microsoft.XMLDOM in asp - get arbitrary nodes

I'm trying to do this in asp, iis5, win2k:

SET objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.load("\\casablanca\Public\changemark.xml")
'objXML.loadXML(BinaryBuffer) 'can i load a binary xml stream directly into the xml object?
                  
SET Node = objXML.documentElement.selectSingleNode("Text/TextLine")
IF LEN (Node.Text) > 0 THEN
     Response.Write " " & Node.Text & " "
END IF
SET Node = NOTHING : SET objXML = NOTHING

I have 3 problems:

(1) the code breaks on the "SET Node" line with "Object required: 'objXML.documentElement'"
(2) the snippet i'm using, if it did work, doesn't do quite what i want. i just found the snippet online. I need to be able to parse an xml document and extract the text/values from any and all occurrances of <TextLine>.
(3) which version of the xmldom dll should i use? i know there are a few. it must work "out of the box" on win2k, xp and win2003. i'm using what i think is the oldest version to ensure that it works on vanilla win2k os. But maybe there's a newer version that comes with win2k.

. . .my xml file looks like this:

 <?xml version="1.0" encoding="UTF-8" ?>
- <IGCMarkupDocument xmlns="http://www.somedomain.com" revision="4" majorversion="0" minorversion="0">
- <PageList pagecount="1">
- <Page index="0">
- <AuthorList authorcount="1">
- <Author name="johne">
- <Text id="0" time="1100715019" color="255,0,0" fontsize="1.60284" italic="false" bold="false" opaque="false" underline="false" font="Arial" hyperlink="">
-  <TextLine>text on drawing in markup</TextLine>
  </Text>
- <Changemark id="1" time="1100715030" color="255,0,0" hyperlink="">
  <Title>Description of changemark, for john</Title>
  <Comment>This is the details of the changemarks for Johns Changemark</Comment>
- <Viewstate Extents="true">
  <Page>0</Page>
  <ScaleFactor>1.44467</ScaleFactor>
  <Rotation>0.0</Rotation>
- <EyePoint>
  <x>367.5</x>
  <y>244.0</y>
  </EyePoint>
- <DeviceRect>
  <top>0</top>
  <left>0</left>
  <bottom>706</bottom>
  <right>1157</right>
  </DeviceRect>
- <LayerTable LayerCount="1">
  <LayerBlock>1</LayerBlock>
  </LayerTable>
  </Viewstate>
  </Changemark>
  </Author>
  </AuthorList>
  </Page>
  </PageList>
  </IGCMarkupDocument>

LVL 11
SweatCoderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony PerkinsCommented:
If you can lose the namespace as in:

<?xml version="1.0" encoding="UTF-8" ?>
<!--IGCMarkupDocument xmlns="http://www.somedomain.com" revision="4" majorversion="0" minorversion="0"-->
<IGCMarkupDocument revision="4" majorversion="0" minorversion="0">
      <PageList pagecount="1">
            <Page index="0">
                  <AuthorList authorcount="1">
                        <Author name="johne">
                              <Text id="0" time="1100715019" color="255,0,0" fontsize="1.60284" italic="false" bold="false" opaque="false" underline="false" font="Arial" hyperlink="">  
                                    <TextLine>text on drawing in markup</TextLine>  
                              </Text>
                              <Changemark id="1" time="1100715030" color="255,0,0" hyperlink="">  
                                    <Title>Description of changemark, for john</Title>  
                                    <Comment>This is the details of the changemarks for Johns Changemark</Comment>
                                    <Viewstate Extents="true">  
                                          <Page>0</Page>  
                                          <ScaleFactor>1.44467</ScaleFactor>  
                                          <Rotation>0.0</Rotation>
                                          <EyePoint>  
                                                <x>367.5</x>  
                                                <y>244.0</y>  
                                          </EyePoint>
                                          <DeviceRect>  
                                                <top>0</top>  
                                                <left>0</left>  
                                                <bottom>706</bottom>  
                                                <right>1157</right>  
                                          </DeviceRect>
                                          <LayerTable LayerCount="1">  
                                                <LayerBlock>1</LayerBlock>  
                                          </LayerTable>  
                                    </Viewstate>  
                              </Changemark>  
                        </Author>  
                  </AuthorList>  
            </Page>  
      </PageList>  
</IGCMarkupDocument>

Than it is as simple as this:

Dim objXml
Dim Nodes
Dim Node

Set objXml = Server.CreateObject("Microsoft.XMLDOM")
objXml.async = False
If objXml.Load("\\casablanca\Public\changemark.xml") Then
   Set Nodes = objXml.selectNodes("IGCMarkupDocument/PageList/Page/AuthorList/Author/Text/TextLine")
   For Each Node In Nodes
           Response.Write "&nbsp;" & Node.Text & "&nbsp;"
   Next
   Set Nodes = Nothing
Else
           Response.Write objXml.parseError.reason
End If
Set objXml = Nothing

If you cannot, than it becomes somewhat more difficult ...
0
SweatCoderAuthor Commented:
thanks for the response. yes, i can lose the namespace if needed. but from your syntax it appears that i can only retrieve the value for a specific instance of TextLine, with a specifc heirarchy. There may be many instances throughout the document, even though this particular xml doc only has one.

how can i get all instances? is there a way to get all instances of any arbitrary element regardless of its tree depth or location? for example, if i wanted to extract the text of all <FOO></FOO> elements, regardless of position, heirarchy, or whatever, is there a command that will do that? that's really what i'm looking for, because i'm wanting to get more than just <TextLine>. . .i used that as my only example for simplicity.

THANKS.
0
Anthony PerkinsCommented:
>>how can i get all instances? <<
Change this:
Set Nodes = objXml.selectNodes("IGCMarkupDocument/PageList/Page/AuthorList/Author/Text/TextLine")

To:
Set Nodes = objXml.selectNodes("//TextLine")

or:
Set Nodes = objXml.getElementsByTagName("TextLine")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SweatCoderAuthor Commented:
you're beautiful! works great.
0
SweatCoderAuthor Commented:
here's the final working implementation, in case it might help somebody else:

SET objXML = Server.CreateObject("Msxml2.DomDocument")
objXml.async = False
PathToXML = Server.MapPath("./changemark.xml")
writeme "PathToXML: " & PathToXML
If objXml.Load(PathToXML) Then
      'Set Nodes = objXml.getElementsByTagName("TextLine")
      Set Nodes = objXml.selectNodes("//TextLine")
      For Each Node In Nodes
            Response.Write "&nbsp;" & Node.Text & "&nbsp;"
      Next
      Set Nodes = Nothing
Else
      Response.Write "ERROR: " & objXml.parseError.reason
End If
Set objXml = Nothing
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.