Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a column in SQL

SQL
CREATE TABLE [dbo].[SYS_LookUpTableSettings](
    [TableName] [varchar](150) NOT NULL,
    [FormWidth] [int] NULL,
    [FormHeight] [int] NULL,
    [ListViewStyleXML] [xml] NULL,
 CONSTRAINT [PK_SYS_LookUpTableSettings] PRIMARY KEY CLUSTERED


i want to use this xml to mapping to Listview column..
how can i convert this column ListViewStyleXML using xml datatype to XmlDocument..





Regards
Sun..
Posted

 
Share this answer
 
xmlDoc.LoadXml("String xml get from database")
 
Share this answer
 
Comments
Maciej Los 29-Nov-14 9:20am    
This is not an answer. Please delete it to avoid down-voting. To post a comment, use "Have a question or comment" widget.
I assume you man the specific XmlDocument object as defined in http://msdn.microsoft.com/en-us/library/system.xml.xmldocument%28v=vs.110%29.aspx[^]

This object support LoadXml method and solution 2 hints that very briefly.

(Consider using XDocument instead.)
When you read an XML column in dot net, it becomes a XmlType http://msdn.microsoft.com/en-us/library/system.data.sqltypes.sqlxml%28v=vs.110%29.aspx[^]

This is ultimately an XmlReader object which you could manipulate like this:

XML
static void Main(string[] args)
        {
            using (var mem = new MemoryStream())
            {
                /* Simulates your XmlType data field */
                var writer = new StreamWriter(mem);
                var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><root><data>chicks</data></root>";
                writer.Write(xml);
                writer.Flush();
                mem.Position = 0;
                XmlReader rdr = XmlReader.Create(mem);

                /*Example of manimuplating data*/
                var xdoc = XDocument.Load(rdr);
                IEnumerable<XElement> found = xdoc.Root.Elements("data");
                Console.WriteLine("my data was: " + found.First().Value);
                Console.ReadKey();

            }
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900