How to access element names with dots and spaces?

R

Ragnar Heil

This line works fine for me:
Set objDOMnode = objDom.selectSingleNode("//headline")
strHeadline = objDOMnode.Text

Now I want to get the value from this node:

<nitf>
- <head>
- <docdata>
- <date.issue norm="20020308T153751+0100" />

Why does these line not give the correct results?
Set objDOMnode = objDom.selectSingleNode("//date.issue norm")
strDate= objDOMnode.Text
 
J

Johannes Koch

Ragnar said:
Now I want to get the value from this node:

<nitf>
- <head>
- <docdata>
- <date.issue norm="20020308T153751+0100" />

Why does these line not give the correct results?
Set objDOMnode = objDom.selectSingleNode("//date.issue norm")
strDate= objDOMnode.Text

1. get the element node for "date.issue"
2. get the attribute value for "norm"
 
R

Richard Tobin

Ragnar Heil said:
- <date.issue norm="20020308T153751+0100" />

Why does these line not give the correct results?
Set objDOMnode = objDom.selectSingleNode("//date.issue norm")

You saeem to be treating this as if it were an element called
"date.issue norm". It isn't, it's an element called "date.issue"
with an attribute called "norm".

Element names can't have spaces in.

-- Richard
 
R

Ragnar Heil

Thank you both for your replies!

I tried two ways to get the value

1) Set objDateNode = objDom.selectSingleNode("//date.issue")
Set DateNodeAttr = objDateNode.Attributes
norm = DateNodeAttr.getNamedItem("norm")
strDate = norm.xml

2) DateNodeAttrLength = DateNodeAttr.length
For i = 1 To DateNodeAttrLength
strDate = DateNodeAttr(i).Value
Next

what is the prefered way?
 
R

Ragnar Heil

Thank you both for your replies!

Now I tried two ways to get the value of the attribute:

1) Set objDateNode = objDom.selectSingleNode("//date.issue")
Set DateNodeAttr = objDateNode.Attributes
norm = DateNodeAttr.getNamedItem("norm")
strDate = norm.xml

2) DateNodeAttrLength = DateNodeAttr.length
For i = 1 To DateNodeAttrLength
strDate = DateNodeAttr(i).Value
Next

Both ways dont work :-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top