[thelist] DOMDocument - was XPATH woes
Scott Dexter
dexilalolai at yahoo.com
Tue May 11 12:52:04 CDT 2004
>
> I have the DOMDocument with the XML loaded
> ...
> <bobtypes>
> <bob id="4"></bob>
> <bob id="7"></bob>
> <bob id="10"></bob>
> </bobtypes>
> ...
>
> to return "4,7,10"
>
whatcha gonna end up doing is writing a loop to output your list; a
simple XPATH query in the DOMDocument ain't gonna produce the list (I
could be wrong here, I'm not an XPATH guru)
Have you tried:
Set oIDList = oDOM.SelectNodes("/bobtypes/bob")
if oIDList is Nothing then
' nothing there, do whateever you must
ids = ""
else
For each oID in oIDList
ids = ids & oID.getAttribute("id") & ","
Next
' hack the trailing comma
ids = left(ids,len(ids)-1)
end if
(or something similar to the above, it was off the top of my head)
I've poked around the MS XML docs, and their XPATH stuff is
XSLT-focused, but there are some gems to get out of it:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/sdk_intro_6g53.asp
Now, there may be a way with XPATH to enumerate the attributes with
the DOMDocument, but I've not spent the time looking, maybe the
secret is in the SDK somewhere....
Hope that helps
Scott
More information about the thelist
mailing list