Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: how to check for empty nodw ? [Thread Next] Re: how to check for empty nodw ?To: NULL Date: 5/3/2006 2:54:00 PM
shafiqrao@g... wrote:
> Thanks for the reply Martin, Here is the ASP file, which includes the
> XML string ... does this make sence now ?? I want to validate that
> employee_id should never be empty ...
As said, for an element node you should check hasChildNodes() e.g.
XMLString = _
"<data><version>1.0</version><employee><employee_id></employee_id>" & _
"<comments>freetext</comments></employee></data>"
Set XmlDocument = CreateObject("Msxml2.DOMDocument.3.0")
If XmlDocument.loadXML(XMLString) Then
XmlDocument.setProperty "SelectionLanguage", "XPath"
For Each Id In xmlDocument.selectNodes("//employee_id")
If Not Id.hasChildNodes() Then
Response.Write "id should not be empty"
End If
Next
Else
Response.Write "parse error: " & xmlDocument.parseError.reason
End IF
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
