| Author |
DOM and XPath Predicates - Shouldn't this work?
|
|
| Michael Geist 2005-03-16, 7:03 pm |
| My XML looks like this:
<?xml version="1.0" ?>
<CollectionGroups>
<CollectionGroup LongName="XXXX IntrAnet Sites" ShortName="Intranet">
<Collection>PASTEL</Collection>
<Collection>PASTEL_III</Collection>
<Collection>Intranet_FSYS</Collection>
<Collection>PASTEL_II</Collection>
<Collection>Intranet_Web_Sites</Collection>
</CollectionGroup>
<CollectionGroup LongName="XXXX Internet Sites" ShortName="Internet">
<Collection>XXXX_Internet_Web_Sites</Collection>
</CollectionGroup>
</CollectionGroups>
I am trying to return a attribute of the CollectionGroup (parent of
Collection) based on the value a Collection with the following line: (all of
the this is server-side so escapes are not an issue)
Response.write
xmlcollectiongroups.selectSingleNode("//CollectionGroup[Collection='" &
sourceColl & "']").getAttribute("LongName")
when the value of sourceColl is the text for the first child of either
<CollectionGroup> this works fine but if sourceColl is the text for any other
child I get:
Microsoft VBScript runtime error '800a01a8'
Object required: '[object]'
I have investigated XPath predicate syntax and it seems that my syntax is
corect. Can you tell me what I am missing?
| |
|
| Your xpath is correct. I can't reproduce the error with your example. The
problem should exist somewhere other than the posted part.
--
Pohwan Han. Seoul. Have a nice day.
"Michael Geist" <MichaelGeist@discussions.microsoft.com> wrote in message
news:D4B013C1-FDD5-4C5C-B036-A63729B11A87@microsoft.com...
> My XML looks like this:
>
> <?xml version="1.0" ?>
> <CollectionGroups>
> <CollectionGroup LongName="XXXX IntrAnet Sites" ShortName="Intranet">
> <Collection>PASTEL</Collection>
> <Collection>PASTEL_III</Collection>
> <Collection>Intranet_FSYS</Collection>
> <Collection>PASTEL_II</Collection>
> <Collection>Intranet_Web_Sites</Collection>
> </CollectionGroup>
> <CollectionGroup LongName="XXXX Internet Sites" ShortName="Internet">
> <Collection>XXXX_Internet_Web_Sites</Collection>
> </CollectionGroup>
> </CollectionGroups>
>
> I am trying to return a attribute of the CollectionGroup (parent of
> Collection) based on the value a Collection with the following line: (all
> of
> the this is server-side so escapes are not an issue)
>
> Response.write
> xmlcollectiongroups.selectSingleNode("//CollectionGroup[Collection='" &
> sourceColl & "']").getAttribute("LongName")
>
> when the value of sourceColl is the text for the first child of either
> <CollectionGroup> this works fine but if sourceColl is the text for any
> other
> child I get:
>
> Microsoft VBScript runtime error '800a01a8'
>
> Object required: '[object]'
>
> I have investigated XPath predicate syntax and it seems that my syntax is
> corect. Can you tell me what I am missing?
>
>
| |
| Michael Geist 2005-03-21, 6:57 pm |
| You are correct. I discovered (after a few frustrating hours) that XPath
Predicates are (evidently) not supprted by msxml.dll.
Server.CreateObject("Msxml2.DOMDocument.3.0")
needed to be:
Server.CreateObject("Msxml2.DOMDocument.5.0")
I needed to add msxml5.dll to my server.
Thank for your reply anyway.
"Han" wrote:
> Your xpath is correct. I can't reproduce the error with your example. The
> problem should exist somewhere other than the posted part.
>
> --
> Pohwan Han. Seoul. Have a nice day.
> "Michael Geist" <MichaelGeist@discussions.microsoft.com> wrote in message
> news:D4B013C1-FDD5-4C5C-B036-A63729B11A87@microsoft.com...
>
>
| |
| Oleg Tkachenko [MVP] 2005-03-22, 6:38 pm |
| Michael Geist wrote:
> You are correct. I discovered (after a few frustrating hours) that XPath
> Predicates are (evidently) not supprted by msxml.dll.
>
> Server.CreateObject("Msxml2.DOMDocument.3.0")
>
> needed to be:
>
> Server.CreateObject("Msxml2.DOMDocument.5.0")
>
> I needed to add msxml5.dll to my server.
No, that's wrong. XPath is supported since MSXML3. In MSXML3 it's not
selection language by default and can be made that using
"SelectionLanguage" property.
--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |