473,404 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Append XML document

Hi,

I posted this in "microsoft.public.xml.msxml-webrelease" but now
realize it should probably have been in the ASP group. Sorry if that
causes any problems.

I have an XML document like:
<MainNode>
<Value>First Value</Value>
</MainNode>
<MainNode>
<Value>Second Value</Value>
</MainNode>
<MainNode>
<Value>Third Value</Value>
</MainNode>
<MainNode>
<Value>Fourth Value</Value>
</MainNode>
</dataroot>

I need to append information to this file using ASP. How do I do this?
I am just starting out in XML so sample code would really help.

Also, I may need to remove a node from this file ... is that possible?
If so, how?

Thanks!!
- Gary

Dec 12 '06 #1
4 3401

<gl****@yahoo.comwrote in message
news:11**********************@73g2000cwn.googlegro ups.com...
Hi,

I posted this in "microsoft.public.xml.msxml-webrelease" but now
realize it should probably have been in the ASP group. Sorry if that
causes any problems.

I have an XML document like:
<MainNode>
<Value>First Value</Value>
</MainNode>
<MainNode>
<Value>Second Value</Value>
</MainNode>
<MainNode>
<Value>Third Value</Value>
</MainNode>
<MainNode>
<Value>Fourth Value</Value>
</MainNode>
</dataroot>

I need to append information to this file using ASP. How do I do this?
I am just starting out in XML so sample code would really help.

Also, I may need to remove a node from this file ... is that possible?
If so, how?

Thanks!!
- Gary
Have a run through this tutorial:-

http://www.w3schools.com/dom/default.asp

also:-

http://www.w3schools.com/xpath/default.asp
Dec 12 '06 #2
Thanks, I'll go through it.

- Gary
------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------

Anthony Jones wrote:
<gl****@yahoo.comwrote in message
news:11**********************@73g2000cwn.googlegro ups.com...
Hi,

I posted this in "microsoft.public.xml.msxml-webrelease" but now
realize it should probably have been in the ASP group. Sorry if that
causes any problems.

I have an XML document like:
<MainNode>
<Value>First Value</Value>
</MainNode>
<MainNode>
<Value>Second Value</Value>
</MainNode>
<MainNode>
<Value>Third Value</Value>
</MainNode>
<MainNode>
<Value>Fourth Value</Value>
</MainNode>
</dataroot>

I need to append information to this file using ASP. How do I do this?
I am just starting out in XML so sample code would really help.

Also, I may need to remove a node from this file ... is that possible?
If so, how?

Thanks!!
- Gary

Have a run through this tutorial:-

http://www.w3schools.com/dom/default.asp

also:-

http://www.w3schools.com/xpath/default.asp
Dec 12 '06 #3
gl****@yahoo.com wrote:
Hi,

I posted this in "microsoft.public.xml.msxml-webrelease" but now
realize it should probably have been in the ASP group. Sorry if that
causes any problems.

I have an XML document like:
<MainNode>
<Value>First Value</Value>
</MainNode>
<MainNode>
<Value>Second Value</Value>
</MainNode>
<MainNode>
<Value>Third Value</Value>
</MainNode>
<MainNode>
<Value>Fourth Value</Value>
</MainNode>
</dataroot>
this is not legal xml - it's missing a <dataroottag. I will assume the
xml actually starts with that tag.
>
I need to append information to this file using ASP. How do I do
this? I am just starting out in XML so sample code would really help.

Also, I may need to remove a node from this file ... is that possible?
If so, how?
Where is this xml coming from? A file? Are you building it in code? I
will assume it is contained in a file:

<%
dim xmldoc, root, node
set xmldoc=createobject("msxml2.domdocument")
xmldoc.load("filename.xml")
set root = xmldoc.documentelement

'To add a MainNode with "Fifth Value", do this:
set node = xmldoc.createelement("MainNode")
node.text = "Fifth Value"
root.appendchild node
response.write xmldoc.xml & "<br><hr>"

'To remove the "Second Value" node:
set node=nothing
set node = xmldoc.selectsinglenode("//MainMode[. = 'Second Value']")
if not node is nothing then
root.removechild node
end if
response.write xmldoc.xml & "<br><hr>"
%>

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Dec 12 '06 #4
Bob,

Yes, the <dataroottag is in the XML file, I just removed it for the
posting.

Thanks for the help!!

- Gary
--------------------------------------------------------------------------------------------------------

Bob Barrows [MVP] wrote:
gl****@yahoo.com wrote:
Hi,

I posted this in "microsoft.public.xml.msxml-webrelease" but now
realize it should probably have been in the ASP group. Sorry if that
causes any problems.

I have an XML document like:
<MainNode>
<Value>First Value</Value>
</MainNode>
<MainNode>
<Value>Second Value</Value>
</MainNode>
<MainNode>
<Value>Third Value</Value>
</MainNode>
<MainNode>
<Value>Fourth Value</Value>
</MainNode>
</dataroot>

this is not legal xml - it's missing a <dataroottag. I will assume the
xml actually starts with that tag.

I need to append information to this file using ASP. How do I do
this? I am just starting out in XML so sample code would really help.

Also, I may need to remove a node from this file ... is that possible?
If so, how?
Where is this xml coming from? A file? Are you building it in code? I
will assume it is contained in a file:

<%
dim xmldoc, root, node
set xmldoc=createobject("msxml2.domdocument")
xmldoc.load("filename.xml")
set root = xmldoc.documentelement

'To add a MainNode with "Fifth Value", do this:
set node = xmldoc.createelement("MainNode")
node.text = "Fifth Value"
root.appendchild node
response.write xmldoc.xml & "<br><hr>"

'To remove the "Second Value" node:
set node=nothing
set node = xmldoc.selectsinglenode("//MainMode[. = 'Second Value']")
if not node is nothing then
root.removechild node
end if
response.write xmldoc.xml & "<br><hr>"
%>

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Dec 12 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Koms Bomb | last post by:
document.write will flush current document content. I've found I can use DOM to append some element to the document, but I think append html text directly is better. Is it possible to append html...
2
by: brian | last post by:
user input accepted via a input in the form. this value needs to be appended to the current url (explained below) ie say present url is www.xyz.com and the user is asked to enter his string and...
3
by: J Krugman | last post by:
This question refers to the DOM. I would like to dynamically append some small amount of text to the all-text content of a <pre> node. I suppose that I could extract the existing content, and...
3
by: Jonathan Buckland | last post by:
Can someone give me an example how to append data without having to load the complete XML file. Is this possible? Jonathan
2
by: Matrix | last post by:
Greetings I want to append records in a XML file,I use XMLTextWriter,but i found it only create a XML file,not append records in exist XML file.why?...
8
by: Kelly Sellers | last post by:
Short version: is it possible to set OutputTo so that it will append to an existing RTF document instead of creating a new document each time? (I'm using Access XP) Full scenario: I generate...
3
by: barry | last post by:
I have the following: function(NAMED) { sString.Append("document.forms.NAMED.style.visibility = 'hidden'") } and would like to convert the NAMED into the object it represents - for example in...
3
by: juicy | last post by:
I have create 4 check box, every check on the check box will append text in textarea and any uncheck on check box will remove text in text area. Please give some guide on how to control this.
1
by: mentor | last post by:
I tried this way, but don't work. in current document, first get the node var aNode = document.getElementById("anode"); then, import the node to the other target document, and append it, ...
0
by: Hags007 | last post by:
I have a XML file I am working with. This file has been created by hand and I now need to develop a PHP script that will create it in the same format. Here is what I have thus far: $query =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.