XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML 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 September 19th, 2003, 05:37 AM
baolong baolong is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 17 baolong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb remove one node in xml???

Hi all,
This is 'manage_accounts.xml' file:
<?xml version = "1.0"?>
<MANAGE_ACCOUNTS>
<USER >
<USERNAME>a</USERNAME>
<PASSWORD>a</PASSWORD>
</USER>

<USER >
<USERNAME>b</USERNAME>
<PASSWORD>b</PASSWORD>
</USER >

<USER >
<USERNAME>c</USERNAME>
<PASSWORD>c</PASSWORD>
</USER >
</MANAGE_ACCOUNTS>

i want to remove node USER and it's content if i enter 'username' in textbox == 'username' in one node:
for ex:
enter "b" -> remove node USER which contain user b
result must be:

<?xml version = "1.0"?>
<MANAGE_ACCOUNTS>
<USER >
<USERNAME>a</USERNAME>
<PASSWORD>a</PASSWORD>
</USER>

<USER >
<USERNAME>c</USERNAME>
<PASSWORD>c</PASSWORD>
</USER >
</MANAGE_ACCOUNTS>

this is my script to do this:
<script language = "javascript">
<XML ID="customers" SRC = "manage_accounts.xml"></XML>
function delete_user()
{
var input = remove_form.txtUsername.value.toLowerCase();
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("manage_accounts.xml")

customers.recordset.moveFirst();
while (!customers.recordset.EOF)
{
var currentUserName = new String(customers.recordset("USERNAME"))
//change to lowercase
currentUserName = currentUserName.toLowerCase();

if(input == currentUserName)
{
var remove_node = xmlDoc.selectSingleNode("/MANAGE_ACCOUNTS/USER")
xmlDoc.documentElement.removeChild(remove_node)
}
customers.recordset.moveNext();
}//end of while (!customers.recordset.EOF)
}
</script>

but when i enter "a"or "b"or"c"-> it's alway delete the first node
result alway is:
<?xml version = "1.0"?>
<MANAGE_ACCOUNTS>
<USER >
<USERNAME>b</USERNAME>
<PASSWORD>b</PASSWORD>
</USER >

<USER >
<USERNAME>c</USERNAME>
<PASSWORD>c</PASSWORD>
</USER >
</MANAGE_ACCOUNTS>

i don't know how to solve this problem?

please help me, it's in urgent!
Thanks a lot..

Reply With Quote
  #2  
Old September 19th, 2003, 12:33 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Try something like:
Code:
 var remove_node = xmlDoc.selectSingleNode("/MANAGE_ACCOUNTS/USER[USERNAME='" + input + "']")
xmlDoc.documentElement.removeChild(remove_node) 

Reply With Quote
  #3  
Old September 20th, 2003, 10:10 PM
baolong baolong is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 17 baolong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
YES, thank you very much mr. Bricker42!
it's work greate!

Thanks again..

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > remove one node in 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 6 hosted by Hostway
Stay green...Green IT