GetElementsByTagName: object required

Discussion in 'XML' started by Ragnar Heil, Apr 25, 2005.

  1. Ragnar Heil

    Ragnar Heil Guest

    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
     
    Ragnar Heil, Apr 25, 2005
    #1
    1. Advertising

  2. Ragnar Heil wrote:

    > 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


    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.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Apr 25, 2005
    #2
    1. Advertising

  3. Ragnar Heil

    Ragnar Heil Guest

    Martin Honnen <> wrote in
    news:426d2422$0$7512$-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'
    > 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
     
    Ragnar Heil, Apr 25, 2005
    #3
  4. Ragnar Heil

    Ragnar Heil Guest

    Martin Honnen <> wrote in
    news:426d2422$0$7512$-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'
    > 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
     
    Ragnar Heil, Apr 26, 2005
    #4
  5. Ragnar Heil wrote:

    > Martin Honnen <> wrote in
    > news:426d2422$0$7512$-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'
    >>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)


    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/
     
    Martin Honnen, Apr 26, 2005
    #5
  6. Ragnar Heil

    Ragnar Heil Guest

    Martin Honnen <> wrote in message news:<426e41d1$0$10496$-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!
     
    Ragnar Heil, Apr 27, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=

    SelectNodes vs. GetElementsByTagName

    =?Utf-8?B?Sm9l?=, Nov 2, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    41,294
    =?Utf-8?B?Sm9l?=
    Nov 2, 2005
  2. mynamehere
    Replies:
    0
    Views:
    477
    mynamehere
    Dec 14, 2003
  3. Danny
    Replies:
    1
    Views:
    438
    wooks
    Jul 23, 2004
  4. Simon Dahlbacka

    xml getElementsByTagName w/o recursion?

    Simon Dahlbacka, Feb 11, 2004, in forum: Python
    Replies:
    2
    Views:
    1,273
    Chris Herborth
    Feb 11, 2004
  5. Max
    Replies:
    1
    Views:
    604
    Martin Honnen
    Aug 9, 2006
Loading...

Share This Page