473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Read xml string into XmlReader

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
Feb 1 '06 #1
2 7237
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

"wapsiii" <wa*****@otmail.com> wrote in message
news:gk********************************@4ax.com...
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

Feb 1 '06 #2
1.1 ahh. via the StringReader - thanks... :)
On Wed, 1 Feb 2006 07:44:50 -0500, "Matt Dinovo"
<matt_at_swiftus_dot_com> wrote:
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

"wapsiii" <wa*****@otmail.com> wrote in message
news:gk********************************@4ax.com.. .
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

Feb 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Garyrek | last post by:
Hi I have an url where I have xml data POSTED and I need to parse the URL to read the data - Meanwhile here is my xml data =================================== <?xml version="1.0"...
3
by: jason | last post by:
i am using an XMLValidatingReader in a manner similar to the following code example: string sReturn = ""; XmlValidatingReader oXML = new XmlValidatingReader(sXMLString, XmlNodeType.Document,...
1
by: Chua Wen Ching | last post by:
Hi there, I have some problems when reading XML file. 1. First this, is what i did, cause i can't seem to read "sub elements or tags" values, so i place those values into attributes like this....
3
by: Daniel | last post by:
in C# how do i transform an xml document with an xsl document when my xml document is a string and my xsl document is a string? the msdn examples only show how to do it with steams and files. in my...
9
by: Jon Paal | last post by:
how can I read an xml file and convert it to a string or convert an XmlTextReader to a string
0
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it verifies the login information it should display the SessionID and enable some button . I appreciate your help and thanku...
3
by: Dan Aldean | last post by:
Hi, I create this XML document: <?xml version="1.0"?> <Bookstore> <Book Genre="Novel" Style="hardcover"> <author> <first-name>Margaret</first-name> <last-name>Atwood</last-name> </author>
3
by: ano | last post by:
Hi, Anyone knows how to get "xmlns" value from XML file? For example, how to check that this xml file has a xmlns or not? Or how to read the xmlns value? <bookstore...
8
by: Martin Eckart | last post by:
Hi folks, Who can explain me why the following expression does not result in getting the correct type, but null: Type t = Type.GetType("System.Xml.XmlReader"); For "System.String" it works...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.