Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Write List to XML and back
Message
De
10/12/2015 10:52:19
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 4.0
OS:
Windows 10
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01628791
Message ID:
01628793
Vues:
43
As MyList knows nothing about the intended structure ("Choices", "Channel"), impossible without "magic strings", which is BAD coding.
Think about creating an XML document as "table" with column info and table name Choices as your intermediate DS.
From that DS you can write out - guessing that either IPersist or IStream are available on your XML handler object.

Dunno if there are controls accepting XML "rowsources" in ASP.net, but getting the list out of the XML document should be doable using standard methods, but must fit into the planned/used fwk architecture. Serializing to XML is more typical of objects, as the property names map to the XML entries. But nothing more than a method is needed and provided the strings to use in the XML plus the list, if there is not already such a beast in existance ;-)

upd:
If this is in line with the localstore / offsite capable web app discussions from the last days: A data flow map and the needed transformations might clear up some ideas and where to put functionality to resolve the remaining issues.

upd2:
in line with my idea on code / database first, perhaps it is easier if you write the xml by hand - only in the dynamic cases where you have to look of items like a file list you should recur to building the XML doc via code as you did for MyList. You have to have the functionality to create your choices from a read XML IAC ;-)

>Hi,
>
>I have been Googling for this question and find many suggestions but none that I understand and see simple.
>
>I have a List (example below) and I want it to create an XML file and save it in a folder.
>
>
>List<string> MyList = new List<string>();
>MyList.Add( "ABC" );
>MyList.Add( "CBS" );
>MyList.Add( "NBC" );
>
>// Now I want to write the above list to an XML that will look like this:
><?xml version="1.0"?>
><Choices>
>        <Channel>ABC</Channel>
>        <Channel>CBS</Channel>
>        <Channel>NBC</Channel>
></Choices>
>
>
>TIA for any suggestions.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform