Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml

Status
Not open for further replies.

adamdavies

Programmer
May 21, 2003
20
AU
How do i create a new blank xml file with C#
Then populate it with data from textboxes.

thanks
adam
 
Don't know about C# (not hand time or necessity for it) but in C/C++, the basic method is just to generate a text file:
Code:
   /* This is C */
   #include <stdio.h>
   void writeStrings(char** aList) {
      FILE* hfOut = fopen(&quot;myfile.xml&quot;, &quot;wt&quot;);
      if (hfOut != NULL) {
         fprintf(hfOut, &quot;<?xml version=\&quot;1.0\&quot;?>\n&quot;);
         fprintf(hfOut, &quot;<MyData>\n&quot;);
         while (*aList != NULL) {
            fprintf(hfOut, &quot;<Data>%s</Data>\n&quot;, *aList);
            ++aList;
         }
         fprintf(hfOut, &quot;</MyData>\n&quot;);
         fclose(hfOut);
      }
      return;
   }
   // Then call it with:
   static char* apszData[] {
         &quot;Data One&quot;
      ,  &quot;Data Value Two&quot;
      ,  &quot;More data value (3)&quot;
      ,  NULL
   };
   writeString(apszData);
Lots of other things though: e.g., you need to make sure that '<', '>' and '&' in the data are encoded properly (as &gt;, &lt;, *amp;, etc.).

Hope this helps.


[tt]________________________________________________________________
[pc2]Roger
Life is a game of cards in which the deck contains only jokers.[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top