Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Linq To Xml From Xml Column in Database

$
0
0

All, I have a database field with a string xml column.

I was trying to query the database for each string value and create a new XDocument / XElement and then query the xml for certain values. I keep getting the following error, when I use the string value from the database ... (This is from Linqpad)

Data at the root level is invalid. Line 1, position 1

However, if I take the same value from the database and create an xml file from it. It works fine.

This seems to be an encoding issue; but I haven't been able to solve it. I would rather not have to query each record, write it to a file and then process it. Any ideas on how to solve this problem?

my linq to sql query is ..

var query = from c in CmsContentXmls
where c.NodeId.Equals("1136")
select c.Xml;

my linq to xml query is ...

string sampleXML = query.ToString();
var doc = XElement.Load(new StringReader(sampleXML));

var results =
from e in doc.Descendants()
select e.Parent;
dpimental


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>