EDN Admin
Well-known member
Say i want to get the account details and write to the xml file...
<br/>
I traverse through each account with the following code,
static BankAccount GetAccount()<br/>
{<br/>
<br/>
BankAccount customerAccount = null;<br/>
long accountNumber = 0;<br/>
Console.WriteLine("nEnter Your Account Number: ");<br/>
if (long.TryParse(Console.ReadLine(), out accountNumber))<br/>
{<br/>
<br/>
foreach (BankAccount acct in allAccounts)<br/>
{<br/>
BankAccount current = acct;<br/>
if (current.AccountNumber == accountNumber)<br/>
{<br/>
customerAccount = current;<br/>
break;<br/>
}<br/>
}<br/>
<br/>
<br/>
}
But i dont know how to write it in xml
I could make only this...
public static void GenerateXML()<br/>
{<br/>
XmlTextWriter writer = new XmlTextWriter("AllAccounts.xml", null);<br/>
writer.Formatting = Formatting.Indented;<br/>
writer.WriteStartElement("Accounts");<br/>
writer.WriteEndElement();<br/>
}
Problem:
Traverse through all accounts collection and write all the members of every bank account as xml string element within “Account” element. Every “Account” element should represent an individual bank account.<br/>
<br/>
View the full article
<br/>
I traverse through each account with the following code,
static BankAccount GetAccount()<br/>
{<br/>
<br/>
BankAccount customerAccount = null;<br/>
long accountNumber = 0;<br/>
Console.WriteLine("nEnter Your Account Number: ");<br/>
if (long.TryParse(Console.ReadLine(), out accountNumber))<br/>
{<br/>
<br/>
foreach (BankAccount acct in allAccounts)<br/>
{<br/>
BankAccount current = acct;<br/>
if (current.AccountNumber == accountNumber)<br/>
{<br/>
customerAccount = current;<br/>
break;<br/>
}<br/>
}<br/>
<br/>
<br/>
}
But i dont know how to write it in xml
I could make only this...
public static void GenerateXML()<br/>
{<br/>
XmlTextWriter writer = new XmlTextWriter("AllAccounts.xml", null);<br/>
writer.Formatting = Formatting.Indented;<br/>
writer.WriteStartElement("Accounts");<br/>
writer.WriteEndElement();<br/>
}
Problem:
Traverse through all accounts collection and write all the members of every bank account as xml string element within “Account” element. Every “Account” element should represent an individual bank account.<br/>
<br/>
View the full article