473,382 Members | 1,332 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,382 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 1281

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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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

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.