October 27, 2011 at 8:40 am
I have a process where I am querying a database that has an NTEXT column that contains XML (should be valid XML). In my data flow I need to shred the XML to get about 5 values to add as columns to the data flow. Here's what I'm attempting:
System.Text.UnicodeEncoding encoding= new System.Text.
byte[] bytes = Row.XMLData.GetBlobData(0, (int)Row.XMLData.Length);
System.Xml.Linq.XDocument xDoc = Xdocument.Load(encoding.GetString(bytes));
Row.PolicyNumber = xDoc.Element("ElementName").Value;
I'm getting an error when trying to load the xDoc. The error is "invalid uri the uri string is too long" and I'm not finding any good answers in Binoogle.
So is there a better way?
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
October 27, 2011 at 12:11 pm
Okay, I'm not that smart. I have the answer. Here's the new code:
System.Text.UnicodeEncoding encoding= new System.Text.
byte[] bytes = Row.XMLData.GetBlobData(0, (int)Row.XMLData.Length);
StringReader sr = new StringReader(encoding.GetString(bytes));
System.Xml.Linq.XDocument xDoc= Xdocument.Load(sr);
XNamespace xNs = xDoc.Root.Name.Namespace;
var xdata = (from policy in xDoc.Descendants(xNs + "data").Descendants(xNs + "policy")
select new
{
policyNumber = policy.Element(xNs + "PolicyNumbersJustPolicyNumber").Value
}).SingleOrDefault();
I was trying to load a document not a stream.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply