GetElementsByTagName: object required

R

Ragnar Heil

with a special method of my application I generate this XML-tree:

<tcm:RenderInstruction xmlns:tcm="http://myNamespace">
<tcm:Item xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="tcm:16-12817-64"
xlink:title="20050309_Enterprise_Information_Integration - 16-12814
Page" xlink:type="simple"/>
<tcm:ActivateBlueprinting>false</tcm:ActivateBlueprinting>
<tcm:ActivateWorkflow>false</tcm:ActivateWorkflow>
<tcm:RenderMode>Publish</tcm:RenderMode>
<tcm:publicationTarget xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="0-2-65537" xlink:title="Staging on local system"
xlink:type="simple"/>
</tcm:RenderInstruction>

Now I want to get this value: "tcm:16-12817-64" (node: tcm:Item)

I tried many different approaches like
set itemNode = objXML.selectSingleNode("/tcm:RenderInstruction/tcm:Item/@xlink:href")
---
Set itemNode = objXML.selectSingleNode("*[local-name() = 'tcm:Item]")
---
set itemNode = objXML.GetElementsByTagName("tcm:Item")

I always get the "object required"-error


thanks in advance
Ragnar
 
M

Martin Honnen

Ragnar said:
with a special method of my application I generate this XML-tree:

<tcm:RenderInstruction xmlns:tcm="http://myNamespace">
<tcm:Item xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="tcm:16-12817-64"
xlink:title="20050309_Enterprise_Information_Integration - 16-12814
Page" xlink:type="simple"/>
<tcm:ActivateBlueprinting>false</tcm:ActivateBlueprinting>
<tcm:ActivateWorkflow>false</tcm:ActivateWorkflow>
<tcm:RenderMode>Publish</tcm:RenderMode>
<tcm:publicationTarget xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="0-2-65537" xlink:title="Staging on local system"
xlink:type="simple"/>
</tcm:RenderInstruction>

Now I want to get this value: "tcm:16-12817-64" (node: tcm:Item)

I tried many different approaches like
set itemNode = objXML.selectSingleNode("/tcm:RenderInstruction/tcm:Item/@xlink:href")

Are you using MSXML? Make sure you have at least MSXML version 3 then
you can do
objXML.setProperty "SelectionLanguage", "XPath"
objXML.setProperty "SelectionNamespaces",
"xmlns:tcm='http://myNamespace' xmlns:xlink='http://www.w3.org/1999/xlink"
then using those prefixes in XPath expression works e.g.
Set itemNode =
objXML.selectSingleNode("/tcm:RenderInstruction/tcm:Item/@xlink:href")

Watch out for line wraps the posting introduces but which are not
allowed in VBScript.
 
R

Ragnar Heil

Are you using MSXML? Make sure you have at least MSXML version 3 then
you can do
objXML.setProperty "SelectionLanguage", "XPath"
objXML.setProperty "SelectionNamespaces",
"xmlns:tcm='http://myNamespace'
xmlns:xlink='http://www.w3.org/1999/xlink" then using those prefixes
in XPath expression works e.g.
Set itemNode =
objXML.selectSingleNode("/tcm:RenderInstruction/tcm:Item/@xlink:href")

Hi Martin

yes, I am using MS XML 4.
Thank you for your input, gonna try it tomorrow

Ragnar
 
R

Ragnar Heil

Are you using MSXML? Make sure you have at least MSXML version 3 then
you can do
objXML.setProperty "SelectionLanguage", "XPath"
objXML.setProperty "SelectionNamespaces",
"xmlns:tcm='http://myNamespace'
xmlns:xlink='http://www.w3.org/1999/xlink" then using those prefixes
in XPath expression works e.g.
Set itemNode =
objXML.selectSingleNode("/tcm:RenderInstruction/tcm:Item/@xlink:href")

setting the properties does not work this way because I dont have an
object (as I thought)

The XML-output is a string and I want to read out the value of this node
("/tcm:RenderInstruction/tcm:Item/@xlink:href")


Ragnar
 
M

Martin Honnen

Ragnar said:
setting the properties does not work this way because I dont have an
object (as I thought)

If you are using MSXML 4 why don't you have an XML document object?
If you have a string with XML markup then you can nevertheless create an
XML DOM document object, when you have that you need to call loadXML to
parse the string.
 
R

Ragnar Heil

Martin Honnen said:
If you have a string with XML markup then you can nevertheless create an
XML DOM document object, when you have that you need to call loadXML to
parse the string.

as soon as you do it the right way, it works :)

thank you, Martin!
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top