Click here to Skip to main content
14,240,872 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have a column in 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
Rate this:
Please Sign up or sign in to vote.

Solution 1

   
Rate this:
Please Sign up or sign in to vote.

Solution 2

xmlDoc.LoadXml("String xml get from database")
   
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.
Rate this:
Please Sign up or sign in to vote.

Solution 3

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:

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();

            }
        }
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100