Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Checking attributes in an XML file
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 11 April 2008 :  11:20:09  Show Profile
I'm building a form at the moment for people to submit link to RSS feeds and I need to verify that all feeds submitted

01. exist, and,
02. follow the specifications found here.

My "pseudo-code" at the moment looks like this:
If the file exists then
 If the file contains and <rdf> tag then
  If that tag has an "xmlns" attribute then
   If that attribute has a value of "http://purl.org/rss/1.0/" then
    File is valid
   else
    File is invalid (wrong namespace)
   end if
  else
   File is invalid (no namespace)
 else
  File is invalid (no <rdf> tag)
else
 File is invalid (doesn't exist)
end if
Not being overly familiar with XML, though, I'm not sure of the best way to translate all of that into VBScript so any pointers would be appreciated.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”

Edited by - Shaggy on 11 April 2008 11:21:57

HuwR
Forum Admin

United Kingdom
20550 Posts

Posted - 11 April 2008 :  12:35:04  Show Profile  Visit HuwR's Homepage
you don't need to be familiar with any xml to do that, just reading lines from a file
just check if the file exists then read it in a line at a time looking for the tag /string you want
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 11 April 2008 :  12:56:39  Show Profile
Fair enough Thought there might have been some funky slick way of doing it with one of the XML objects


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20550 Posts

Posted - 11 April 2008 :  14:33:19  Show Profile  Visit HuwR's Homepage
you can, but it isn't really any more efficient or intuitive, since all you can do is step through it node by node, you could do something along the lines of below, but would need to see a sample of the xml structure to give you the exact string required

Set xmlobj = Server.CreateObject("Microsoft.XMLDOM")
xmlobj.async = false
xmlobj.load (Server.MapPath("your_xml_file.xml"))
Set objNode = xmlobj.SelectSingleNode("rdf/xlmns[field/field_value='http://purl.org/rss/1.0/']")

Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 14 April 2008 :  05:12:39  Show Profile
Thanks, Huw This is what I came up with in the end:
function validrss(u,n)
	dim objRss,strRss
	validrss=true
	if len(u)=0 or isnull(u) then
		validrss=n
		exit function
	end if
	if validlink(u,true) then
		set objRss=server.createobject("Msxml2.ServerXMLHTTP.3.0")
		objRss.open "GET",u,false
		objRss.send
		if objRss.status<>200 then
			validrss=false
		else
			strRss=objRss.responsexml.xml
			if instr(strRss,"<rdf:RDF")=0 or instr(strRss,"xmlns=""http://purl.org/rss/1.0/""")=0 then validrss=false
		end if
		set objRss=nothing
	else
		validrss=false
	end if
end function

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2019 Snitz™ Communications Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000 Version 3.4.07