LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default XML in excel

Hello - I am pretty comfortable with vba in excel. However, I don't know
anything about xml. I am trying to query an xml file. Here is a piece of
the xml:

<?xml version="1.0" encoding="UTF-8" ?
- <GetCategoriesResponse xmlns="urn:ebay:apis:eBLBaseComponents"
<Timestamp2006-04-28T14:27:28.172Z</Timestamp
<AckSuccess</Ack
<Version457</Version
<Builde457_core_Bundled_2818483_R1</Build
- <CategoryArray
- <Category
<BestOfferEnabledtrue</BestOfferEnabled
<AutoPayEnabledtrue</AutoPayEnabled
<CategoryID20081</CategoryID
<CategoryLevel1</CategoryLevel
<CategoryNameAntiques</CategoryName
<CategoryParentID20081</CategoryParentID
<Expiredfalse</Expired
<IntlAutosFixedCatfalse</IntlAutosFixedCat
<LeafCategoryfalse</LeafCategory
<Virtualfalse</Virtual
<ORPAfalse</ORPA
<LSDfalse</LSD
</Category
- <Category
<BestOfferEnabledtrue</BestOfferEnabled
<AutoPayEnabledtrue</AutoPayEnabled
<CategoryID37903</CategoryID
<CategoryLevel2</CategoryLevel
<CategoryNameAntiquities (Classical, Amer.)</CategoryName
<CategoryParentID20081</CategoryParentID
<Expiredfalse</Expired
<IntlAutosFixedCatfalse</IntlAutosFixedCat
<LeafCategoryfalse</LeafCategory
<Virtualfalse</Virtual
<ORPAfalse</ORPA
<LSDfalse</LSD
</Category
- <Category
<BestOfferEnabledtrue</BestOfferEnabled
<AutoPayEnabledtrue</AutoPayEnabled
<CategoryID37905</CategoryID
<CategoryLevel3</CategoryLevel
<CategoryNameEgyptian</CategoryName
<CategoryParentID37903</CategoryParentID
<Expiredfalse</Expired
<IntlAutosFixedCatfalse</IntlAutosFixedCat
<LeafCategorytrue</LeafCategory
<Virtualfalse</Virtual
<ORPAfalse</ORPA
<LSDfalse</LSD
</Category

I need to be able to filter by CategoryParentID and return an array of
CategoryNames. I know that I need to utilize XPath, but there is really no
documentation in the excel help files. This is what I have tried so far:

Dim xmlDoc As New Msxml2.DOMDocument40
Dim objNodeList As IXMLDOMNodeList
xmlDoc.async = False
xmlDoc.Load ("G:\CatTree.xml")
xmlDoc.setProperty "SelectionLanguage", "XPath"
Set objNodeList = xmlDoc.selectNodes("//Category")
' I get nothing returned for objNodeList
MsgBox objNodeList.Length ' this is 0
For Each x In objNodeList ' skips this loop (because it is empty)
MsgBox x.XML
Next
End Sub

I think that I need to utilize selectionNameSpaces (but i'm not sure how -
I'm not even completely sure I understand what a namespace is).

If someone could point me towards some good examples of querying xml from
vba in excel, that would be great. Specifically, the above example is the
ebay category tree. So examples of using ebay's CatTree.xml would be even
better. I can't find anything out there in vba (and I have really tested the
limits of google's computing abilities).

--
Thanks,
Mike
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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



All times are GMT +1. The time now is 06:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"