Read xml string into XmlReader

  • Thread starter Thread starter wapsiii
  • Start date Start date
W

wapsiii

How do I read the xml string below (saved in varchar field in ms sql
db) into a XmlReader or a XmlTextReader?

<?xml version="1.0" encoding="utf-8"?>
<Class_bizContact xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Property_PersonId>22</Property_PersonId>
<Property_UserId>11</Property_UserId>
<Property_ContactTypeId>1</Property_ContactTypeId>
<Property_ContactStatusId>1</Property_ContactStatusId>
<Property_Subject>Test serialization</Property_Subject>
<Property_Description>hello hello hello</Property_Description>
</Class_bizContact>

Morten
 
You didn't say which version of .NET you're using, so here's both:

1.1:

Dim rdr as new System.Xml.XmlTextReader(new
System.IO.StringReader(<xmlstring>))

2.0

Dim rdr as System.Xml.XmlReader = System.Xml.XmlReader.Create(new
System.IO.StringReader(<xmlstring>))

HTH,

Matt Dinovo
 
1.1 ahh. via the StringReader - thanks... :)


You didn't say which version of .NET you're using, so here's both:

1.1:

Dim rdr as new System.Xml.XmlTextReader(new
System.IO.StringReader(<xmlstring>))

2.0

Dim rdr as System.Xml.XmlReader = System.Xml.XmlReader.Create(new
System.IO.StringReader(<xmlstring>))

HTH,

Matt Dinovo
 
Back
Top