Web Design and Development Forums

handling xml errors

This is a discussion on "handling xml errors" within the XML, RSS & Atom section. This forum, and the thread "handling xml errors are both part of the Program Your Website category.

Old Sep 4th, 2006, 16:36   #1 (permalink)
New Member
 
Join Date: Sep 2006
Location: assadfg
Age: 26
Posts: 1
handling xml errors

I use the following code with the yahoo search api:

Code: Select all
<%@ 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  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
handling, xml, errors

Thread Tools
Rate This Thread
Rate This Thread:

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

BB 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
Two errors - Similar Errors too. PicoDeath CSS Forum 6 Jul 27th, 2007 18:06
Php Image handling Accurax PHP Forum 10 Feb 27th, 2007 23:06
Character Encoding Handling spinal007 ASP Forum 0 Jun 13th, 2006 11:21
Form handling Tim356 PHP Forum 2 Feb 28th, 2005 23:55
Form handling Process in ASP? sazhagianambi ASP Forum 4 May 27th, 2004 12:59



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 14:51.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59