Parsing out a data Island in a FrontPage document using VBA

  • Thread starter Ken Cox [Microsoft MVP]
  • Start date
K

Ken Cox [Microsoft MVP]

I'm trying to use VBA and the FrontPage object model to retrieve data from
an embedded XML data island.

In the code below, I can open the file (sample.htm) and get the content of
the HEAD tag. However, the tags collection doesn't pick out the xml tag,
obviously because it isn't seen as an object in the object model.

There's a reference in the documentation to FPHTMLUnknownElement and
IHTMLElement which may provide a solution here, but so far they escape me.

The simple demonstration code appears below.

Thanks for any help,

Ken


Sub GetDataIsland()
Dim pg As WebFile
Set pg = ActiveWeb.RootFolder.Files("sample.htm")
pg.Open
Dim pgwindow
Set pgwindow = ActiveWebWindow.PageWindows("sample.htm")
' Need to parse the XML in here
Set headtag = pgwindow.Document.all.tags("head")
For Each obj In headtag
Debug.Print obj.outerHTML
Next
End Sub

<html>
<head>
<title></title>
<xml>
<MSHelp:TOCTitle Title="The title of the page goes here"/>
<MSHelp:RLTitle Title="The title of the page goes here"/>
<MSHelp:Keyword Index="K" Term="title parsing" />
<MSHelp:Keyword Index="K" Term="xml data" />
</xml>
</head>
<body>
Sample page for parsing the XML Data Island
</body>
</html>
 
S

Steve Easton

Ken,
Don't you need to also define the xml tag and then call it by using the headtag as the object.
something like this:

Sub GetDataIsland()
Dim pg As WebFile
Set pg = ActiveWeb.RootFolder.Files("sample.htm")
pg.Open
Dim pgwindow
Set pgwindow = ActiveWebWindow.PageWindows("sample.htm")
' Need to parse the XML in here
Set headtag = pgwindow.Document.all.tags("head")
Set xmltag = headtag.Document.all.tags("xml") 'added this line
For Each obj In xmltag 'changed this line.
Debug.Print obj.outerHTML
Next
End Sub

This is off the top of my head so it might need some tweaking

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
K

Ken Cox [Microsoft MVP]

Thanks Steve, but that's not quite it. I don't think FrontPage sees headtag
as that kind of an object. Still looking for a solution....

Ken
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top