Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Append XML document

Reply
Thread Tools

Append XML document

 
 
glbdev@yahoo.com
Guest
Posts: n/a
 
      12-12-2006
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

 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      12-12-2006

<> wrote in message
news: 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


 
Reply With Quote
 
 
 
 
glbdev@yahoo.com
Guest
Posts: n/a
 
      12-12-2006
Thanks, I'll go through it.

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

Anthony Jones wrote:
> <> wrote in message
> news: 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


 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      12-12-2006
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 <dataroot> tag. 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.


 
Reply With Quote
 
glbdev@yahoo.com
Guest
Posts: n/a
 
      12-12-2006
Bob,

Yes, the <dataroot> tag is in the XML file, I just removed it for the
posting.

Thanks for the help!!

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

Bob Barrows [MVP] wrote:
> 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 <dataroot> tag. 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
the address of list.append and list.append.__doc__ HYRY Python 10 09-26-2007 09:41 AM
converting a variable within a append document.forms string barry ASP .Net 3 12-23-2005 03:18 AM
Refer to an XML document from within an XML document Manish Hatwalne XML 1 07-13-2004 10:24 AM
Help on including one XML document within another XML document using XML Schemas Tony Prichard XML 0 12-12-2003 03:18 PM
Is it possible to append html text to current document? Koms Bomb Javascript 1 07-01-2003 02:59 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57