473,396 Members | 2,014 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.

ReadXML Illegal characters in path

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
10 14077
* 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
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


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
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
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


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
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


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
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
<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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: deko | last post by:
Is there a way to check user input for illegal characters? For example, a user enters something into a text box and clicks OK. At that point I'd like to run code such as this: illegal =...
2
by: Karl Koscher | last post by:
I'm trying to communicate with a USB device using C#. I'm able to determine the device path using P/Invoke and SetupDiGetClassDevs, SetupDiEnumDeviceInterfaces, and SetupDiGetDeviceInterfaceDetail,...
1
by: Steve Grahovac | last post by:
I have been having trouble the last few days opening any ASP.NET web forms in the design view in the designer. Every time I clicked on an aspx file I got a message box with the error "Unable to...
3
by: Juhan | last post by:
Hi! I have a strange error in a console application that is hosted by IIS 5.0 and invokes a web service hosted on the same machine. A request form the web comes in and it is dispatched to a...
3
by: Eckhard Schwabe | last post by:
I only found one post on Google where someone mentions the same problem with a DataSet: XmlDataReader in .Net 1.1 can not read XML files from a path which contains "%10" or "%3f". code to...
16
by: DBC User | last post by:
Hi, I have a small XML file, I uploaded to a web page. I have the following code to convert the content I downloaded from web to xml and is giving "Illegal characters in path", but when I try to...
1
by: Thomas | last post by:
Hi, I have written a simple web application in asp.net 1.1.4322. following is the code written in Page_Load private void Page_Load(object sender, System.EventArgs e) { string str =...
1
by: ray well | last post by:
i saved the state of a data set and table via MyDs.WriteXmlSchema("MyDs.xsd") MyDs.WriteXml("MyDs.xml") i was able to read them back in and display the info in the database by ...
1
by: crusson | last post by:
(edited to add): this is in Visual Basic .net I am at a complete loss... I've been building a program on my machine, running it out of the developer with the f5 key and builidng it and running...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.