By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,773 Members | 1,779 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,773 IT Pros & Developers. It's quick & easy.

ReadXML Illegal characters in path

P: n/a
Getting error: Illegal characters in path
what's wrong with this?

string xmlSR =
"<XmlDS><table1><phone>Value1</phone><name>jake</name></table1></XmlDS>";
myDataSet.ReadXml(xmlSR, XmlReadMode.IgnoreSchema);
DataList5.DataSource = myDataSet;
DataList5.DataBind();

Also, what's the best way to return XML from a method for binding into
a web control?

myDataSet.ReadXml(x.y(), XmlReadMode.IgnoreSchema);

I'm trying this, but it's resulting in error about no datasource, also,
its only returning the first row:

public static string yt()
{
string conn = "Data
Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirecto ry|\\xx.mdf;Integrated
Security=True;User Instance=True";
using (SqlConnection connection = new SqlConnection(conn))
{
connection.Open();
SqlCommand cmd = new SqlCommand("select * from book2 for
xml path", connection);
cmd.CommandType = CommandType.Text;
XmlReader xr = cmd.ExecuteXmlReader();
xr.MoveToContent();
return(xr.ReadOuterXml());

Sep 23 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
* we*******@1stmiami.com wrote in microsoft.public.dotnet.xml:
>Getting error: Illegal characters in path
what's wrong with this?

string xmlSR =
"<XmlDS><table1><phone>Value1</phone><name>jake</name></table1></XmlDS>";
myDataSet.ReadXml(xmlSR, XmlReadMode.IgnoreSchema);
Presumably ReadXml does not take a XML string but the path to a XML file
which the above is not since it has illegal characters that cannot occur
in a path.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Sep 23 '06 #2

P: n/a
newbie here trying to piece this together

now getting:

DataBinding: 'System.Xml.XmlElement' does not contain a property with
the name 'phone

at the control:

<asp:DataList ID="DataList5" runat="server" Style="z-index: 110;
left: 362px; position: absolute;
top: 10px" Width="152px" BackColor="#DEBA84"
BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2" GridLines="Both">
<ItemTemplate>
1:
<asp:Label ID="PhoneLabel" runat="server" Text='<%#
Eval("phone") %>'></asp:Label><br />
2:
<asp:Label ID="Label3" runat="server" Text='<%#
Eval("name") %>' Width="105px"></asp:Label<br />
</ItemTemplate>
trying code:

string xx =
"<root><phone>Value1</phone><name>jake</name></root>";
XmlDocument d = new XmlDocument();
d.LoadXml(xx);
DataList5.DataSource=d.SelectNodes("/root/*");
DataList5.DataBind();


Bjoern Hoehrmann wrote:
* we*******@1stmiami.com wrote in microsoft.public.dotnet.xml:
Getting error: Illegal characters in path
what's wrong with this?

string xmlSR =
"<XmlDS><table1><phone>Value1</phone><name>jake</name></table1></XmlDS>";
myDataSet.ReadXml(xmlSR, XmlReadMode.IgnoreSchema);

Presumably ReadXml does not take a XML string but the path to a XML file
which the above is not since it has illegal characters that cannot occur
in a path.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld..de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Sep 23 '06 #3

P: n/a


we*******@1stmiami.com wrote:
Getting error: Illegal characters in path
what's wrong with this?

string xmlSR =
"<XmlDS><table1><phone>Value1</phone><name>jake</name></table1></XmlDS>";
myDataSet.ReadXml(xmlSR, XmlReadMode.IgnoreSchema);
DataList5.DataSource = myDataSet;
DataList5.DataBind();
You should pass in a string with a URL as the first argument to ReadXml.
At least that is one option. You can also pass in an XmlReader and based
on what you have shown that is what you want to do, simply let your
method return that reader that ExecuteXmlReader gives you, then pass
that reader to ReadXml
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataSetClassReadXmlTopic4.asp>
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataSetClassReadXmlTopic8.asp>
On the other hand you seem to have relational data, then you let the
data base convert and return that as XML, then you load the XML into a
DataSet (which is again a relational view of the data). Maybe you are
just experiementing and playing with the different APIs, but if not I am
not sure why you let the data base return XML at all, you can simply
make a normal SQL query and load that result in a DataSet.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 23 '06 #4

P: n/a
I am experimenting. My eventual goal is bind from a web service that
will return an xml dataset. The webmethod must return xml as I"m not
sure if the clients will always be .net or sql server or ado.net. Im
still stuck. Please see my prior post, seems my issue is not formating
of the xml. Thanks!
Martin Honnen wrote:
we*******@1stmiami.com wrote:
Getting error: Illegal characters in path
what's wrong with this?

string xmlSR =
"<XmlDS><table1><phone>Value1</phone><name>jake</name></table1></XmlDS>";
myDataSet.ReadXml(xmlSR, XmlReadMode.IgnoreSchema);
DataList5.DataSource = myDataSet;
DataList5.DataBind();

You should pass in a string with a URL as the first argument to ReadXml.
At least that is one option. You can also pass in an XmlReader and based
on what you have shown that is what you want to do, simply let your
method return that reader that ExecuteXmlReader gives you, then pass
that reader to ReadXml
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataSetClassReadXmlTopic4.asp>
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataSetClassReadXmlTopic8.asp>
On the other hand you seem to have relational data, then you let the
data base convert and return that as XML, then you load the XML into a
DataSet (which is again a relational view of the data). Maybe you are
just experiementing and playing with the different APIs, but if not I am
not sure why you let the data base return XML at all, you can simply
make a normal SQL query and load that result in a DataSet.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 23 '06 #5

P: n/a
okay. I did that and IT WORKED!

myDataSet.ReadXml(t2.G2());
DataList5.DataSource = myDataSet;
DataList5.DataBind();


public class t2
{
public static XmlReader G2()
{
string conn = "Data Source=....";
using (SqlConnection connection = new SqlConnection(conn))
{
connection.Open();
SqlCommand cmd = new SqlCommand("select * from book2 for
xml RAW", connection);
cmd.CommandType = CommandType.Text;
XmlReader xr = cmd.ExecuteXmlReader();
return (xr);
Thing is though.. I want the the eventual web sevice return the lowest
common demominator as I don't know what will try to consume it. Any
suggestions?

Martin Honnen wrote:
we*******@1stmiami.com wrote:
Getting error: Illegal characters in path
what's wrong with this?

string xmlSR =
"<XmlDS><table1><phone>Value1</phone><name>jake</name></table1></XmlDS>";
myDataSet.ReadXml(xmlSR, XmlReadMode.IgnoreSchema);
DataList5.DataSource = myDataSet;
DataList5.DataBind();

You should pass in a string with a URL as the first argument to ReadXml.
At least that is one option. You can also pass in an XmlReader and based
on what you have shown that is what you want to do, simply let your
method return that reader that ExecuteXmlReader gives you, then pass
that reader to ReadXml
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataSetClassReadXmlTopic4.asp>
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataSetClassReadXmlTopic8.asp>
On the other hand you seem to have relational data, then you let the
data base convert and return that as XML, then you load the XML into a
DataSet (which is again a relational view of the data). Maybe you are
just experiementing and playing with the different APIs, but if not I am
not sure why you let the data base return XML at all, you can simply
make a normal SQL query and load that result in a DataSet.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 23 '06 #6

P: n/a


we*******@1stmiami.com wrote:

Thing is though.. I want the the eventual web sevice return the lowest
common demominator as I don't know what will try to consume it. Any
suggestions?
There is microsoft.public.dotnet.framework.aspnet.webservic es to discuss
web services.

In terms of the DataSet ReadXml method it is also possible to read in a
string with XML e.g.
aDataSet.ReadXml(new StringReader(stringWithXml))
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataSetClassReadXmlTopic3.asp>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 23 '06 #7

P: n/a
DataSet myDataSet = new DataSet();
myDataSet.ReadXml = new StringReader(test.Gogetit());

results in error:

Error 1 Cannot assign to 'ReadXml' because it is a 'method group'
public class test
{
public static string Gogetit()
{
string conn "..."
using (SqlConnection connection = new SqlConnection(conn))
{
connection.Open();
//SqlCommand cmd = new SqlCommand("select * from book2 for
xml path", connection);
SqlCommand cmd = new SqlCommand("select * from book2 for
xml RAW", connection);
cmd.CommandType = CommandType.Text;
XmlReader xr = cmd.ExecuteXmlReader();
xr.MoveToContent();
return(xr.ReadOuterXml());

Martin Honnen wrote:
we*******@1stmiami.com wrote:

Thing is though.. I want the the eventual web sevice return the lowest
common demominator as I don't know what will try to consume it. Any
suggestions?

There is microsoft.public.dotnet.framework.aspnet.webservic es to discuss
web services.

In terms of the DataSet ReadXml method it is also possible to read in a
string with XML e.g.
aDataSet.ReadXml(new StringReader(stringWithXml))
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataSetClassReadXmlTopic3.asp>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 23 '06 #8

P: n/a


we*******@1stmiami.com wrote:
DataSet myDataSet = new DataSet();
myDataSet.ReadXml = new StringReader(test.Gogetit());
>>In terms of the DataSet ReadXml method it is also possible to read in a
string with XML e.g.
aDataSet.ReadXml(new StringReader(stringWithXml))
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataSetClassReadXmlTopic3.asp>
Use what I posted, I did not tell you to try to assign to ReadXml, you
should call it as shown.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 23 '06 #9

P: n/a
okay, that worked.

my method seems to have a bug, and I'm kinda newbie. it's only
returning the first

<row name="somename" phone="somephone" />

but binding is working.

if I change the select to use for xml path It looks like this and also
works:

<row><name>somename</name><phone>somephone</phone></row>

What's recommended for cross platform any consumer use of xml? I'm sure
when I turn it into a service there will be an added layer of confusion
for me.

Thanks!

Martin Honnen wrote:
we*******@1stmiami.com wrote:
DataSet myDataSet = new DataSet();
myDataSet.ReadXml = new StringReader(test.Gogetit());

>In terms of the DataSet ReadXml method it is also possible to read in a
string with XML e.g.
aDataSet.ReadXml(new StringReader(stringWithXml))
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataSetClassReadXmlTopic3.asp>

Use what I posted, I did not tell you to try to assign to ReadXml, you
should call it as shown.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 23 '06 #10

P: n/a
<we*******@1stmiami.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Thing is though.. I want the the eventual web sevice return the lowest
common demominator as I don't know what will try to consume it. Any
suggestions?
I suggest that you should not return .NET - specific data types from a web
service if you expect clients which are not running .NET.

The lowest common denominator would be XML. You should define the XML using
a schema, and you should return XML which matches this schema. If you happen
to use a DataSet to create the retuned XML, that's great. But don't return a
DataSet and then expect Java to understand it.

John
Sep 24 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.