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

Best way to generate dynamic XmlElements and Nodes

Hi all, great community!

Let's say I have the following XML document that I want tofollow:

<CallLogs>
<Call>
<Data>
<SubEntry></SubEntry>
<SubEntry></SubEntry>
<SubEntry></SubEntry>
</Data>
</Call>
</CallLogs>

I have an XML writer that will append all the elements and nodes<Call> through </Call> between the <CallLogs> elements. This isdone so that if the file already exists, it will just append tothe current file, without overwriting. This works just dandy. here comes my problem though. The data that goes into a<SubEntry></SubEntry> node is from a dataset. So I will have aline of code that looks like this to create my nodes of text:

XmlText textNode1 =xmlDoc.CreateTextNode(ds.Tables[0].Rows[0][0].ToString());

These text nodes get applied into my schema as follows:

call.AppendChild(data);
data.AppendChild(subEntry1);
subEntry0.AppendChild(textNode1);

I have found from trial and error that the elements must haveunique names (correct?) For instance, if I try the followingcode:

call.AppendChild(data);
data.AppendChild(subEntry1);
subEntry0.AppendChild(textNode1);

call.AppendChild(data);
data.AppendChild(subEntry1);
subEntry0.AppendChild(textNode2);

it will overwrite the previously written node. Makes sense.

What I want to do is dynamically create the subEntry XmlElementsso that I can add accordingly to how many rows are in thedataset. I can't find an optimal method to do so. I would liketo create a new

XmlElement subEntry[i] = xmlDoc.CreateElement("SubEntry");

where i is in accordance to the row count of the dataset. I needto then do the same with the textNodes:

XmlText textNode[i] =xmlDoc.CreateTextNode(ds.Tables[0].Rows[i][0].ToString());

again where i is in accordance to the row count. Is there a wayto make an array of XmlElements or XmlNodes, iterate throughthat array accordingly? Then i can just create the elements andcall the ones that will associate with the row number beingused.

I appreciate any help possible with this.
User submitted from AEWNET (http://www.aewnet.com/)
Nov 16 '05 #1
0 1282

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

Similar topics

0
by: Matt | last post by:
I have a pretty complex schema that I am working with and I am using this to try and create a dynamic interface with a TreeView and ListView control. I believe I can get this to work but when I go...
0
by: k-lo | last post by:
Hi all! Let's say I have the following XML document that I want tofollow: <CallLogs> <Call> <Data> <SubEntry></SubEntry> <SubEntry></SubEntry> <SubEntry></SubEntry>
8
by: slacker | last post by:
By clicking a link on a website I set a USERINFO cookie and then I redirect to a program which ultimately executes an XSL file which dynamically builds an input form. The input form, while having...
1
by: firenet | last post by:
21 function js_reply_msg(node,g_id,u_id,par_id) 22 { 23 node.innerHTML="<FORM><TEXTAREA name=\"msg_con\"><\/TEXTAREA><br><INPUT type=\"submit\" value=\"reply\"><\/FORM>" 24 ...
2
by: Ron M. Newman | last post by:
Hi, Just need a little advice. Id like to build *dynamic* context menus for tree nodes. I'm pretty versed in building context menus and attaching them to tree nodes. My question is, what...
0
by: taylorjonl | last post by:
I am having a problem generating some soap proxies dynamically using almost the exact same code as in the MSDN sample. ...
1
by: Daniel Hilgarth | last post by:
Hello, I am currently trying to use XSLT for the creation of multiple HTML-files from a single XML-File. This HTML-files need to have links to each other. The following information might be...
1
by: doemon | last post by:
Hi, I'm working on a pagination control and I need to dynamically rerender a treeview to display the next set of nodes depending on which page we're on. For example, page 1 will dispaly only...
5
by: sean.gilbertson | last post by:
Hi, I'm sort of new to ASP.NET 2.0 and ASP.NET in general. I have some data that I would like to display in a tabular format, but I'm going to be generating the columns dynamically, and I would...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
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,...

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.