Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

returning all records wich equal a certain value

Status
Not open for further replies.

guestAsh

Technical User
Feb 27, 2004
65
GB
Hi is there anyway of doing the following using ASP? i have the following XML file example:

Code:
<site>
<page>
<url>foo</url>
<title>foo</title>
<owner>foo<owner>
</page>
<page>
<url>foo1</url>
<title>foo1</title>
<owner>foo<owner>
</page>
<page>
<url>foo2</url>
<title>foo2</title>
<owner>foo1<owner>
</page>
<site>

how would i return all records where the <owner> = foo

any idea?
 

IMHO the easiest way is to read the XML into a dataset then use a dataview to filter the data.

SOmething like

dim ds as new dataset
ds.readxml("pathtoxmlfile.xml")
dim dv as new dataview(ds.tables(0))
dv.filter ("owner='foo'")

Then you can loop through the dataviews rows (items I think)

Rob

 
OOPS.. I was thinking dot net

In ado you can load a recorset and do much the same thing.
However off the top of my head, i can't remember how to do that.


 
thanks nocoolhandle - i'll do another google
 
This shows you the bare-minimum how you get and display them.
[tt]
dim xmlfile [green]'given[/green]
xmlfile="yoursitemap.xml"

dim oparser,bret,cnodes,onode
bret=oparser.load(server.mappath(xmlfile))
response.write "bret=" & bret & "<br />" & vbcrlf
if bret then
set cnodes=oparser.selectnodes("//page[owner='foo']")
for each onode in cnodes
response.write replace(replace(onode.xml,">","&gt;"),"<","&lt;") & "<br />" & vbcrlf
next
set cnodes=nothing
end if
set oparser=nothing
[/tt]
 
Thanks tsuji,

That works a treat. can anyone reccomend any good web site that reference XML with ASP
 
I don't know why I left out the line setting up oparser in drafting up!
[tt]
'etc etc
dim oparser,bret,cnodes,onode
[blue]set oparser=server.createobject("msxml2.FreeThreadedDOMDocument")[/blue]
bret=oparser.load(server.mappath(xmlfile))
'etc etc[/tt]
 
>any good web site that reference XML with ASP
You don't need to look anywhere else than the msdn if you want to use xml with asp. It has a very comprehensive and solid documentation on the technologies of xml (including its implementation and proprietary extension).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top