473,224 Members | 1,903 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,224 software developers and data experts.

XMLTextReader - root element is missing

I'm sending xml to a web service by building a string dynamically.
When my web service tries to validate the xml with a schema, I'm
getting the error "the root element is missing". If I use an xml file
saved to disk, I don't get an error.

Does anyone know what the problem could be?

- Cheryl

Public Function ValidateXML(ByVal sXML As String) As String

Dim strReader As StringReader
strReader = New StringReader(sXML)

Dim tr As XmlTextReader = New XmlTextReader(strReader)
Dim sc As XmlSchemaCollection = New XmlSchemaCollection
Dim vr As XmlValidatingReader = New XmlValidatingReader(tr)

Try

sc.Add(Nothing, "c:\FFRMA\Test.xsd")
vr.ValidationType = ValidationType.Schema
vr.Schemas.Add(sc)

AddHandler vr.ValidationEventHandler, AddressOf ValidationCallBack

While (vr.Read())

End While

sErrorMsg = "Success"

Catch ex As Exception

sErrorMsg = ex.Message & ":" & ex.Source

Finally

ValidateXML = sErrorMsg

End Try
Nov 12 '05 #1
4 13742
Cheryl Gilbert wrote:
I'm sending xml to a web service by building a string dynamically.
When my web service tries to validate the xml with a schema, I'm
getting the error "the root element is missing". If I use an xml file
saved to disk, I don't get an error.


Must be some junk before root element. Debug and see what is passed
string. It might be also encoding issue.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
There is nothing before the root element. I've printed the string to the
debug widow, and validated the string in XMLSpy

What possible encoding issue could it be?

Thank you,

Cheryl

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:OV**************@TK2MSFTNGP12.phx.gbl...
Cheryl Gilbert wrote:
I'm sending xml to a web service by building a string dynamically.
When my web service tries to validate the xml with a schema, I'm
getting the error "the root element is missing". If I use an xml file
saved to disk, I don't get an error.


Must be some junk before root element. Debug and see what is passed
string. It might be also encoding issue.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

Nov 12 '05 #3
Cheryl Gilbert wrote:
There is nothing before the root element. I've printed the string to the
debug widow, and validated the string in XMLSpy


Well, can you show some repro?

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #4
Does it provide you any line information where this is happening? If its an
encoding issue, its generally after the xml declaration. However seeing the
line information may help? Send the XML if you want us to take a look.

Thanks,
Amol

"Cheryl Gilbert" <cg******@financialfreedom.com> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
There is nothing before the root element. I've printed the string to the
debug widow, and validated the string in XMLSpy

What possible encoding issue could it be?

Thank you,

Cheryl

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:OV**************@TK2MSFTNGP12.phx.gbl...
Cheryl Gilbert wrote:
I'm sending xml to a web service by building a string dynamically.
When my web service tries to validate the xml with a schema, I'm
getting the error "the root element is missing". If I use an xml file
saved to disk, I don't get an error.


Must be some junk before root element. Debug and see what is passed
string. It might be also encoding issue.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com


Nov 12 '05 #5

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

Similar topics

0
by: Blaz Lipuscek | last post by:
I have a problem with System.Xml.XmlTextReader.ReadInnerXml() Method. By using this method you think it will return a string that contains all child nodes of the current node. I attached a sample...
4
by: Meir S. | last post by:
I think the following is a bug in XmlTextReader: I need to process large XMLs, that are typically constructed of many small elements nested in the root element. Each inner element represents a...
1
by: Koji Ishii | last post by:
I'm trying to read response from a web server using XmlTextReader. Here's a code snippet. WebResponse rs = this.WebRequest.GetResponse(); Stream stm = rs.GetResponseStream(); XmlTextReader...
1
by: Jesper Stocholm | last post by:
I have som XML like this: <root> <Course CourseCode="id1"> <Teacher Name="Some name"/> <Title Titlde="Dansk Titel 1"/> <Title Title="English Title 1"/> <Location Place="Some place"/>...
5
by: Geoff Bennett | last post by:
While parsing an XML document, my TextReader instance skips nodes. For example, in this fragment: <Person Sex="Male" FirstHomeBuyer="No" YearsInCurrentProfession="14"> <RelatedEntityRef...
2
by: Yuriy | last post by:
Hi, any ideas how to read XML fragment from TextReader? XmlTextReader constructor accepts only Stream or string as source Do I miss something? thanks Yuriy
1
by: soupaman | last post by:
Im trying to output some filtered xml using the xmlTextReader I know the code and commenting needs cleaned up and eventually plan to add the values to a dataset. currently what this is doing is...
2
by: pesso | last post by:
I have the following code that's taken and modified from a got_dot_net example. I'm trying to decrypt an Xml file that's been encrypted. I can dump the decrypted stream to the console, but if I...
2
by: CindyH | last post by:
Hi I have a http xml post that I'm trying to read using xmltextreader. This is the xml: <?xml version="1.0"?> <userlist ACTION="newuser" VENDORNAME="H2Digital"> <amouser AMOAID="101"...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.