Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 16th, 2014, 01:09 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default small issue creating sitemap.xml usinf ASP

Im using classic ASP to create sitemap.xml files however I am getting a small issue which I cant figure out. My objective is to obey this:

http://www.sitemaps.org/protocol.html

The issue in my output. I can not figure out how to stop the xmlns="" being printed inside the url tag. it should only be showing in the urlset tag

Here is the cut n paste working ASP/VBScript:

Code:
Dim theDom, theRoot, theParent,theChild, theID, docInstruction

Set theDom = Server.CreateObject("Microsoft.XMLDOM")
Set theRoot = theDom.createElement("urlset")

Set theID = theDom.createAttribute("xmlns")
theID.Text = "http://www.sitemaps.org/schemas/sitemap/0.9"
theRoot.setAttributeNode theID
theDom.appendChild theRoot

Set theParent = theDom.createElement("url")     
  Set theChild = theDom.createElement("loc")
  theChild.Text = "http://someURL.com"
  theRoot.appendChild theParent
  theParent.appendChild theChild

  Set theChild = theDom.createElement("changefreq")
  theChild.Text = "weekly"
  theRoot.appendChild theParent
  theParent.appendChild theChild

Set theParent = theDom.createElement("url")     
  Set theChild = theDom.createElement("loc")
  theChild.Text = "http://someOtherUrl.com"
  theRoot.appendChild theParent
  theParent.appendChild theChild

  Set theChild = theDom.createElement("changefreq")
  theChild.Text = "weekly"
  theRoot.appendChild theParent
  theParent.appendChild theChild

Set docInstruction = theDom.createProcessingInstruction("xml","version='1.0' encoding='UTF-8'")
theDom.insertBefore docInstruction, theDom.childNodes(0)
theDom.Save Server.MapPath("MyXMLDoc.xml")
and here is the output of the XML file it creates. How can I stop the xmlns="" from showing in the url tag but make sure it stays in the urlset tag??

Code:
  <?xml version="1.0" encoding="UTF-8" ?> 
 - <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  - <url xmlns="">
     <loc>http://someURL.com</loc> 
     <changefreq>weekly</changefreq> 
    </url>
 - <url xmlns="">
    <loc>http://someOtherUrl.com</loc> 
    <changefreq>weekly</changefreq> 
   </url>
  </urlset>
__________________
Wind is your friend
Matt

Last edited by mat41; April 16th, 2014 at 02:34 AM..
 
Old April 22nd, 2014, 05:46 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Matt,

I answered this question here: http://stackoverflow.com/questions/2...15919#23215919

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!




Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a skin file issue bpl BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 October 27th, 2009 07:39 PM
Creating XML doc ; writing string(xml format) into KamalRaturi XML 5 May 28th, 2008 05:51 AM
Small issue, someone else may have noticed too mike_remember Forum and Wrox.com Feedback 10 April 4th, 2007 11:53 AM
Creating Dynamic ASP.NET Server Controls Using XML kwilliams XSLT 0 October 6th, 2006 01:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.