Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Directory Submission Service   ClickBooth Network   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 09-04-2006, 09:39 AM   #1 (permalink)
Inactive
 
Join Date: 06-01-06
Posts: 5
iTrader: 0 / 0%
Latest Blog:
None

grobar is liked by many
handling xml errors

I use the following code with the yahoo search api:

Code:
<%@ Language=VBScript %> <% Dim mysearch, mypage, pageinc, xml, objNodeList, objNode, objNode2 mysearch=Left(Request.QueryString("q"),256) mypage = Request.QueryString("p") if mypage=0 then mypage = 1 %> <html> <head> <title>Yahoo! Web Search API In ASP</title> </head> <body> <form method="GET" action="websearch.asp"> <b>Yahoo! Web Search:</b><br> <input type="text" name="q" maxlength=256 size=40 value='<%=mysearch%>' size=15><input type="submit" value="Search!"></form><br> <% if mysearch<>"" then Dim Url Url = "http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=someappid&query=" & Server.URLEncode(mysearch) & "&results=50&start=" & mypage Set XML = Server.CreateObject("msxml2.DOMDocument.3.0") XML.async = false XML.setProperty "ServerHTTPRequest", True XML.validateOnParse = false XML.preserveWhiteSpace = false If Not XML.Load(Url) Then Response.write "<P>ERROR<br>code: " & _ XML.parseError.errorCode & _ "<br>Linea/Col: " & _ XML.parseError.line & "/" & _ XML.parseError.linepos & "</P><br /><p>" & _ XML.parseError.srcText & "</P>" Else Dim rTitle, rSummary, rUrl, rClickUrl, rMimeType, rModDate, rCache pageinc=1 Set objNodeList = XML.getElementsByTagName("Result") For Each objNode In objNodeList For Each objNode2 In objNode.childNodes Select Case objNode2.nodeName Case "Title" rTitle = objNode2.text Case "Summary" rSummary = objNode2.text Case "Url" rUrl = objNode2.text Case "ClickUrl" rClickUrl = objNode2.text Case "MimeType" rMimeType = objNode2.text Case "ModificationDate" rModDate = objNode2.text Case "Cache" rCache = objNode2.text End Select Next ' rURL can contain more than one URL seperated by spaces if InStr(rURL," ")>0 then rURL = Left(rURL,InStr(rURL," ")-1) response.write("<table border=0><tr><td><a href='" & rClickUrl & "'>" & rTitle & "</a><br>" & rSummary & "<br><font color='gray'>Date: " & DateAdd("s", rModDate, "01/01/1970 00:00:00") & " | <a style='color: gray;' href='" & rCache & "'>Cache</a> | MimeType: " & rMimeType & "</font></td></tr></table><br>") rTitle="" rSummary="" rUrl="" rClickUrl="" rMimeType="" rModDate="" rCache="" pageinc=pageinc+1 Next set objNodeList = Nothing end if set xml = nothing if mypage>1 then response.write("<a href=?q=" & Server.URLEncode(mysearch) & "&p=" & cstr(mypage-50)) response.write("><b><<< Previous Page</b></a> | ") end if if pageinc=>16 then response.write("<a href=?q=" & Server.URLEncode(mysearch) & "&p=" & cstr(mypage+50)) response.write("><b>Next Page >>></b></a>") end if %> <br>powered by Yahoo! Search <% end if %> </body> </html>
I am getting an error, presumable because of an ampersand with whitespace that is in one of the results, see specific error below: (notice the ampersand in title?_)

ERROR
code: -1072896749
Linea/Col: 51/99
txt: How to download CBC's technology show Quirks & Quarks to your iPod.http://www.cbc.ca/podcasting/http://...66800text/html

so, how can I handle this? (i dont really even need the title - but if i did, is there a way to ahndle it? is there a way not to return the title at all?
grobar is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 09-04-2006, 10:30 AM   #2 (permalink)
v7n Mentor
 
digiweb's Avatar
 
Join Date: 04-07-06
Location: Manchester, NH
Posts: 770
iTrader: 1 / 100%
digiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of light
Send a message via Yahoo to digiweb Send a message via Skype™ to digiweb
I'm confused

a - is this code websearch.asp?
b - where does it retrieve the value of mysearch?
digiweb is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-04-2006, 10:41 AM   #3 (permalink)
Inactive
 
Join Date: 06-01-06
Posts: 5
iTrader: 0 / 0%
Latest Blog:
None

grobar is liked by many
Quote:
Originally Posted by CarolineBogart
I'm confused

a - is this code websearch.asp?
b - where does it retrieve the value of mysearch?
A) - yes, it is websearch.asp
B) - <input type="text" name="q" maxlength=256 size=40 value='<%=mysearch%>' (form on this page that submits to itself)

so the input that give this error is "links:halifax.ca"

- this is a yahoo search api thing, and there is one line in the results -

"How to download CBC's technology show Quirks & Quarks to your iPod.http://www.cbc.ca/podcasting/http://...66800text/html"

im assuming that the xml cant handle the ampersand with the whitespaces. is there a way to handle this?

thanks for looking
grobar is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors on Load only in I.E hemanthjava Web Design Lobby 5 03-18-2008 03:33 AM
handling unmanaged server Jalpari Dedicated Servers 3 10-22-2007 06:11 AM
.htaccess file handling eloquent Coding Forum 6 02-01-2007 01:07 AM
ServerMatrix handling orders very slowly nextGoal100kVisitors Dedicated Servers 14 07-30-2004 05:09 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 03:32 PM.
© Copyright 2008 V7 Inc

Click Here