473,394 Members | 1,722 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,394 software developers and data experts.

Multiple XML Elements

Hi all,

I need to create an XML file that has multiple instances of elements,
such as

<play>
<name></name>
<form></form>
<set></set>
</play>

<play>
<name></name>
<form></form>
<set></set>
</play>

The idea is that the user can create multiple plays in the xml file.
What's the best way to do this? I create one instance of the elements
with the following code:

play = xmldoc.CreateElement("play");
global.AppendChild(play);

name = xmldoc.CreateElement("name");
xmltext = xmldoc.CreateTextNode(currentPlayNameTextBox.Text) ;
name.AppendChild(xmltext);
play.AppendChild(name);

form = xmldoc.CreateElement("form");
xmltext =
xmldoc.CreateTextNode(formSelComboBox.SelectedItem .ToString());
form.AppendChild(xmltext);
play.AppendChild(form);

set = xmldoc.CreateElement("set");
mltext = xmldoc.CreateTextNode(setSelComboBox.SelectedItem. ToString());
set.AppendChild(xmltext);
play.AppendChild(set);

but if I try to just repeat this I get an error saying "This document
already has an 'XmlDeclaration' node.".

Any help would be much appreciated. Thanks.

Maurice

Mar 24 '06 #1
1 2150
Hello,

It is not possible. A valid XML document can have only one root element. But
you can create document like:

<plays>
<play>
<name></name>
<form></form>
<set></set>
</play>

<play>
<name></name>
<form></form>
<set></set>
</play>
</plays>

Tomek

<ma*************@gmail.com> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.com...
Hi all,

I need to create an XML file that has multiple instances of elements,
such as

<play>
<name></name>
<form></form>
<set></set>
</play>

<play>
<name></name>
<form></form>
<set></set>
</play>

The idea is that the user can create multiple plays in the xml file.
What's the best way to do this? I create one instance of the elements
with the following code:

play = xmldoc.CreateElement("play");
global.AppendChild(play);

name = xmldoc.CreateElement("name");
xmltext = xmldoc.CreateTextNode(currentPlayNameTextBox.Text) ;
name.AppendChild(xmltext);
play.AppendChild(name);

form = xmldoc.CreateElement("form");
xmltext =
xmldoc.CreateTextNode(formSelComboBox.SelectedItem .ToString());
form.AppendChild(xmltext);
play.AppendChild(form);

set = xmldoc.CreateElement("set");
mltext = xmldoc.CreateTextNode(setSelComboBox.SelectedItem. ToString());
set.AppendChild(xmltext);
play.AppendChild(set);

but if I try to just repeat this I get an error saying "This document
already has an 'XmlDeclaration' node.".

Mar 27 '06 #2

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

Similar topics

3
by: Phil Powell | last post by:
Has anyone here ever done a case where you have a select multiple form element and you have to do both server-side and client-side validation? I am honestly not sure how to do it in Javascript (I...
2
by: JeeWee | last post by:
Hi all, I'm looking for a way to "bind" multiple eventhandler function to the same event. In other languages this can often be done by using the += operator, unfortunately this doesn't seem to...
12
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
2
by: areef.islam | last post by:
Hi, I am kinda new to javascript and I am having this problem with selecting multiple options from a select tag. Hope someone can help me out here. here is my code...
4
by: R | last post by:
Hi All, I have problem with sorting nodes I want sort them by columns c1, c2 also I have node <root><sort ActiveField="c0"/></root> ActiveField attribute is set by user. I'm sorting 'row'...
2
by: libsfan01 | last post by:
hi! i have written a function to make visible elements with a certain id. however i intended it to be used to make visible multiple elements but it only appears to switch on the first element it...
5
by: paul_zaoldyeck | last post by:
does anyone know how to validate an xml file against multiple defined schema? can you show me some examples? i'm making here an xml reader.. thank you
2
by: dinkle | last post by:
Hi Y'all, I am pretty new to js and am hitting a few snags. I need to process a multiple select list and pass it onto a PHP script. I can only get the first value in the JS and have no idea how...
5
by: Neil | last post by:
"lyle" <lyle.fairfield@gmail.comwrote in message news:48c3dde7-07bd-48b8-91c3-e157b703f92b@f3g2000hsg.googlegroups.com... Question for you. I'm doing something similar, only, instead of opening...
2
by: helplakshmi | last post by:
Hi All, I am new to php. The form that i am designing has few input input fields with submit and reset button. The functionality of submit and reset are working properly till now. My form ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...

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.