how to check for blank values in xml

wxdqz

New Member
We are using an html page with input boxes and then passing to xml tags whichgoes to an asp page to update an Access database. The problem we are havingis that if a user leaves a value blank, we get a strange error that says"page cannot be displayed." Our database fields allow for zero length andare not required. How can we modify our asp page to check to make sure thatthe fields have been filled out. Our asp page is below. Thank you in advancefor any suggestions.<%@Language= VBScript %><%Response.ContentType = "text/html"Set docReceived = CreateObject ("Microsoft.XMLDOM")docReceived.async = FalsedocReceived.load Request'Add an XML Schema to root node of documentSet rootnode = docReceived.documentElementrootnode.setAttribute "xmlns", "x-schema:" & Server.MapPath("studentlistschema.xml")'Create another XMLDOM object to validate the XML dataSet docTested = CreateObject("Microsoft.XMLDOM")docTested.validateOnParse = TruedocTested.async = FalsedocTested.loadXML(docReceived.xml)'Is the document valid?If docTested.parseError.errorCode = 0 Then'Send "OK" message back to the clientResponse.Write "The XML is valid!"Else'Send details of error back to the clientResponse.Write "Invalid XML!" & vbCrLfResponse.Write "Line Number: " & CStr(docTested.parseError.line)& vbCrLfResponse.Write "Character: " & CStr(docTested.parseError.linepos)& vbCrLfResponse.Write "Source Text: " & docTested.parseError.srcText& vbCrLfResponse.Write "Error code: " & CStr(docTested.parseError.errorCode)& vbCrLfResponse.Write "Description: " & docTested.parseError.reason& vbCrLfResponse.EndEnd IfSet Conn = CreateObject ("ADODB.Connection")Conn.ConnectionString = "ProjectXML"Conn.OpenSet ssnNode = docReceived.selectSingleNode("//ssn").childnodesssnid = ssnNode(0).nodevalueSet fnameNode = docReceived.selectSingleNode("//fname").childnodesfnameid = fnameNode(0).nodevalueSet lnameNode = docReceived.selectSingleNode("//lname").childnodeslnameid = lnameNode(0).nodevalueSet streetNode = docReceived.selectSingleNode("//street").childnodesstreetid = streetNode(0).nodevalueSet cityNode = docReceived.selectSingleNode("//city").childnodescityid = cityNode(0).nodevalueSet stateNode = docReceived.selectSingleNode("//state").childnodesstateid = stateNode(0).nodevalueSet zipNode = docReceived.selectSingleNode("//zip").childnodeszipid = zipNode(0).nodevalueSet areaNode = docReceived.selectSingleNode("//area").childnodesareaid = areaNode(0).nodevalueSet phoneNode = docReceived.selectSingleNode("//phone").childnodesphoneid = phoneNode(0).nodevalueSet emailNode = docReceived.selectSingleNode("//email").childnodesemailid = emailNode(0).nodevalueSQL = "INSERT INTO student (ssn, fname, lname, street, city, state, zip,area, phone, email) VALUES ('" & ssnid & "','" & fnameid & "','" & lnameid& "','" & streetid & "','" & cityid & "','" & stateid & "','" & zipid & "','"& areaid & "','" & phoneid & "','" & emailid & "')"Conn.execute(SQL)Response.Write " Thank you for registering. Your account has been added toour database."Conn.Close%>
 
Back
Top