473,602 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML prepend Child

1 New Member
The reason why I am writing is because I am having trouble with appending information into my XML file and I thought that maybe you could help me out.

What I would like is to have the new information inserted at the top of my XML file and not at the bottom. I was reading about prependChild but I am not getting it to work. Can anyone help me out?

This a function that I call in my asp code that appends information into an XML file.

<%
addContact "c:\projects\xm l\xml","contact .xml"
If err.number <> 0 then Response.write( "Errors occurred while saving your form submission.") Else Response.write( "Your form submission has been saved.")

Function addContact(strX MLFilePath, strFileName)
Dim objDom
Dim objRoot
Dim objRecord
Dim objField
Dim objFieldValue
Dim objattID
Dim objattTabOrder
Dim objPI
Dim blnFileExists

Set objDom = server.CreateOb ject("Microsoft .XMLDOM")
objDom.preserve WhiteSpace = True
blnFileExists = objDom.Load(str XMLFilePath & "\" & strFileName)
If blnFileExists = True Then
Set objRoot = objDom.document Element
Else
Set objRoot = objDom.createEl ement("users")
objDom.appendCh ild objRoot
End If

'Create the new container element for the new record.
Set objRecord = objDom.createEl ement("profile" )
objRoot.appendC hild objRecord 'I think that over here I should write objRoot.prepend Child obijRecord. But I am getting an error

For x = 1 To Request.Form.Co unt
If instr(1,Request .Form.Key(x),"b tn") = 0 Then
'Create an element, "field".
Set objField = objDom.createEl ement(Request.F orm.Key(x))

'Create a new element, "field_valu e".
Set objFieldValue = objDom.createEl ement(Request.F orm.Key(x))

'Set the value of the field_value element equal to the value of the current field in the Form Collection.
objFieldValue.T ext = Request.Form(x)

'Append the field element as a child of the new record container element, contact.
objRecord.appen dChild objField

'Append the field_value element as a child of the field element.
objField.append Child objFieldValue
End If
Next

If blnFileExists = False then 'Create the xml processing instruction.
Set objPI = objDom.createPr ocessingInstruc tion("xml", "version='1.0'" )
'Append the processing instruction to the XML document.
objDom.insertBe fore objPI, objDom.childNod es(0)
End If

'Save the XML document.
objDom.save strXMLFilePath & "\" & strFileName

'Release all of your object references.
Set objDom = Nothing
Set objRoot = Nothing
Set objRecord = Nothing
Set objField = Nothing
Set objFieldValue = Nothing
Set objattID = Nothing
Set objattTabOrder = Nothing
Set objPI = Nothing
End Function
%>


Thank-you indvance
Nov 23 '06 #1
0 1997

Sign in to post your reply or Sign up for a free account.

Similar topics

6
26501
by: flamesrock | last post by:
so I know you can append a string. But how do you *prepend* a string, as shown in the following code #dirList = #string = """position""" #for x in len(dirList): # string += '>> %s'%dirList.pop() #(????????????) # to return
37
5044
by: nobody | last post by:
I am writing a framework that other developers will write plug-ins for. I would like for one of the features of the framework to be to intercept all text written to stdout/stderr and prepend timestamps on each line. I would like for this to work for all the printf-line functions (fprintf, etc...) as well as C++ I/O streams (cout and cerr). The key here is that I would like to get these timestamps on the lines of text written to...
5
3394
by: lazypig06 | last post by:
Hi ! I'd like to ask everyone this question. I am currently maintain a website which have hundreds of pages and lot of subdirectories. Most of these pages contains a common function (let's call it "foo()" on top of each of these pages. I've tried to use auto prepend and .htaccess to prepend a file which contains an exact function foo() that is being used on other pages. I kept getting error "Cannot redeclare foo() in..." when I try to...
1
4184
by: y0sh1 | last post by:
I'm new at using macros in excel and need to prepend zeros to a column of data. i know i'll need an if statement with some kind of loop. the logic goes something like, select cell, if number is less than 9 digits long prepend "0" until it is equal to 9 digits. if equal to 9 digits do nothing and select next. can anyone give me some idea as to how the syntax would look like? any help is much appreciated.
6
1540
by: Geoff Berrow | last post by:
I have a record in a MySql database which can be edited. Each time it is edited I want to give the user the opportunity to summarise the changes, which I store in a field. It doesn't really warrant another table it would be sufficient to prepend the data to the existing data in the field. Sorry if this is really a MySql problem, but at the moment I can only think of a php/html hidden field solution. -- Geoff Berrow (put thecat out...
5
4827
by: lawpoop | last post by:
Hello - Is there an operator where I can prepend a string to a string, without repeating the variable name? I'm aware of the concatenation operator, where you can do $string .= $ending; but I would like to do
0
7920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8268
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5867
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2418
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.