Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > GetElementsByTagName: object required

Reply
Thread Tools

GetElementsByTagName: object required

 
 
Ragnar Heil
Guest
Posts: n/a
 
      04-25-2005
with a special method of my application I generate this XML-tree:

<tcm:RenderInstruction xmlns:tcm="http://myNamespace">
<tcm:Item xmlnslink="http://www.w3.org/1999/xlink"
xlink:href="tcm:16-12817-64"
xlink:title="20050309_Enterprise_Information_Integ ration - 16-12814
Page" xlink:type="simple"/>
<tcm:ActivateBlueprinting>false</tcm:ActivateBlueprinting>
<tcm:ActivateWorkflow>false</tcm:ActivateWorkflow>
<tcm:RenderMode>Publish</tcm:RenderMode>
<tcmublicationTarget xmlnslink="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
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      04-25-2005


Ragnar Heil wrote:

> with a special method of my application I generate this XML-tree:
>
> <tcm:RenderInstruction xmlns:tcm="http://myNamespace">
> <tcm:Item xmlnslink="http://www.w3.org/1999/xlink"
> xlink:href="tcm:16-12817-64"
> xlink:title="20050309_Enterprise_Information_Integ ration - 16-12814
> Page" xlink:type="simple"/>
> <tcm:ActivateBlueprinting>false</tcm:ActivateBlueprinting>
> <tcm:ActivateWorkflow>false</tcm:ActivateWorkflow>
> <tcm:RenderMode>Publish</tcm:RenderMode>
> <tcmublicationTarget xmlnslink="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


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' xmlnslink='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.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Ragnar Heil
Guest
Posts: n/a
 
      04-25-2005
Martin Honnen <(E-Mail Removed)> wrote in
news:426d2422$0$7512$(E-Mail Removed)-online.net:

> 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'
> xmlnslink='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
 
Reply With Quote
 
Ragnar Heil
Guest
Posts: n/a
 
      04-26-2005
Martin Honnen <(E-Mail Removed)> wrote in
news:426d2422$0$7512$(E-Mail Removed)-online.net:


> 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'
> xmlnslink='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
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      04-26-2005


Ragnar Heil wrote:

> Martin Honnen <(E-Mail Removed)> wrote in
> news:426d2422$0$7512$(E-Mail Removed)-online.net:
>
>
>
>>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'
>>xmlnslink='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)


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.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
Ragnar Heil
Guest
Posts: n/a
 
      04-27-2005
Martin Honnen <(E-Mail Removed)> wrote in message news:<426e41d1$0$10496$(E-Mail Removed)-online.net>.

> 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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a VD with required properties on a required Web Server (Windows Advanced Server 2000 has 3 Web Servers) Just D. ASP .Net 0 03-10-2006 06:02 AM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
Error: VBScript runtime (0x800A01A8) Object required: '[object]' Carolyn Speakman XML 1 07-30-2004 07:40 AM
Recordset - Object Required rob ASP .Net 6 06-15-2004 01:36 PM
Object reference required (question) Bucko ASP .Net 1 10-24-2003 11:37 PM



Advertisments