ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 31st, 2003, 11:51 AM
DaronTan DaronTan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Malaysia
Posts: 49 DaronTan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 23 sec
Reputation Power: 6
Send a message via AIM to DaronTan Send a message via MSN to DaronTan Send a message via Yahoo to DaronTan
Question Delete item from xml???

Please tell me wat's wrong with the code below
I'd try both way in the asp file to delete the childnode in xml but it couldn't work

*** News.xml ***
-------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited with XML Spy v4.2 -->
<News>
<Article>
<Head>Test 1</Head>
<Des>Testing 123</Des>
<Date>1/9/2003</Date>
</Article>

<Article>
<Head>Test 2</Head>
<Des>Testing 321</Des>
<Date>1/9/2003</Date>
</Article>
</News>
-------------------------------------------------


*** file.asp ***
-------------------------------------------------
<%
If Request.QueryString("Action")="Delete" Then
Dim strID
Dim objXML
Dim subArticle
Dim objLst
Dim subLst

strID = CInt(Request.Form("selectAnnouncement"))

Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.Load(Server.MapPath("News.xml"))

**** 01 ****
Set objLst = objXML.getElementsByTagName("Article")
Set subLst = objLst.item(strID)
objXML.documentElement.removeChild subLst

**** 02 ****
'Set subArticle = objXML.documentElement.childNodes(strID)
'objXML.documentElement.removeChild (subArticle)

Set childNode = Nothing
End If
%>
-------------------------------------------------

Last edited by DaronTan : August 31st, 2003 at 02:22 PM.

Reply With Quote
  #2  
Old August 31st, 2003, 04:31 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
woah, what neck of the woods are we in here?

To begin with, if you're going to be using XML as a database structure you should use EMPTY elements rather than plain element declaration. Speaking of which, where the hell is your DTD? well, in anycase i guess you don't really need it but it's good programming practice.

well, how about we start out with setting it to the document root?

then how about we get by .getElementsByTagName("blah").

when you get that.
ObjOldChild = objParent.removeChild(objParent.lastChild);

Secondly, you don't have a unique identifier for article. I think that's your problem but i don't work with this form of xml, it's kinda not good and it's generally stressed to use attribute EMPTY elements instead.

This is generally how W3C is aiming
Code:

<NEWS>
   <ARTICLE
           articleID="art01" 
           Des="Testing 123"
           Date="1/9/2003"
           />
  <ARTICLE
          articleID="art02"
          Des="Testing 321"
          etc....


</NEWS>


this will dramatically reduce your document size which will be a big issue since the purpose of XML is marshalling data. You won't see a dramatic speed increase with this since DOM loads everything into memory first, but when you get into SAX and more advacned XML handling methods you'll begin to see a performance increase with attribute usage and 'containment'. But of course performance is a big thing with XML since it's already slow enough, but if i remember correctly you were knew, or maybe it was just new to asp, but in anycase, let me know if you still need help.

Hope this helps, but i'm not a master of doing it the way you're currently handling this.... if you want to switch to my way we can talk =P

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Delete item from xml???


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT