Groups | Blog | Home
all groups > dotnet xml > july 2006 >

dotnet xml : Invalid carachter loading xml


Fabri
7/3/2006 12:02:08 PM
I'm trying to parse a xml source.

1) I query via webservices one table and obtain this output

================================================================
<?xml version="1.0" encoding="utf-8"?>
<ExecuteReaderResult
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.mysite.com">
<DataSet>
<xs:schema id="NewDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>

<xs:element name="id" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">

<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<id>PIPPO</id>
</Table>
<Table diffgr:id="Table2" msdata:rowOrder="1">
<id>PLUTO</id>
</Table>
</NewDataSet>

</diffgr:diffgram>
</DataSet>
<Error>false</Error>
<ErrorText />
</ExecuteReaderResult>

================================================================


2) I try to read it this way:


Dim reader As New XmlTextReader(OutputXML)

' OutputXML is a string with the xml value above



I obtain "invalid carachter"

Can you point me to some workarounds?

I only have to parse <Table> nodes for "PIPPO" and "PLUTO".

Any help appreciated.

Best regards.

--
fabri
MKDS: Joker® - <waiting for ds lite...>
AC:Fabrizio, Kanoemi, 1890 4700 1546
Oleg Tkachenko [MVP]
7/4/2006 12:00:00 AM
[quoted text, click to view]

The argument of the XmlTextReader constructor is XML file path, not XML
content in a string. If you want to read string, use StringReader class:

(C#)
XmlTextReader reader = new XmlTextReader(new StringReader(OutputXML);

or if you are doing .NET 2.0 then

XmlReader reader = XmlReader.Create(new StringReader(OutputXML));

--
Oleg Tkachenko [XML MVP, MCPD]
AddThis Social Bookmark Button