Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / September 2006

Tip: Looking for answers? Try searching our database.

ReadXML Illegal characters in path

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
webmaster@1stmiami.com - 23 Sep 2006 16:13 GMT
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=|DataDirectory|\\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());
Bjoern Hoehrmann - 23 Sep 2006 16:30 GMT
* webmaster@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.
Signature

Björn Höhrmann · mailto:bjoern@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/

webmaster@1stmiami.com - 23 Sep 2006 16:53 GMT
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();

> * webmaster@1stmiami.com wrote in microsoft.public.dotnet.xml:
> >Getting error:  Illegal characters in path
[quoted text clipped - 11 lines]
> Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
> 68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Martin Honnen - 23 Sep 2006 17:01 GMT
> Getting error:  Illegal characters in path
> what's wrong with this?
[quoted text clipped - 4 lines]
> 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/frlr
fSystemDataDataSetClassReadXmlTopic4.asp
>
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fSystemDataDataSetClassReadXmlTopic8.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.

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

webmaster@1stmiami.com - 23 Sep 2006 17:13 GMT
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!

> > Getting error:  Illegal characters in path
> > what's wrong with this?
[quoted text clipped - 19 lines]
> 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.
webmaster@1stmiami.com - 23 Sep 2006 17:31 GMT
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?

> > Getting error:  Illegal characters in path
> > what's wrong with this?
[quoted text clipped - 19 lines]
> 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 - 23 Sep 2006 18:02 GMT
> 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.webservices 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/frlr
fSystemDataDataSetClassReadXmlTopic3.asp
>

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

webmaster@1stmiami.com - 23 Sep 2006 18:29 GMT
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());

> > 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
[quoted text clipped - 7 lines]
>    aDataSet.ReadXml(new StringReader(stringWithXml))
> <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fSystemDataDataSetClassReadXmlTopic3.asp
>
Martin Honnen - 23 Sep 2006 18:37 GMT
> 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/frlr
fSystemDataDataSetClassReadXmlTopic3.asp
>

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

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

webmaster@1stmiami.com - 23 Sep 2006 18:56 GMT
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!

> > DataSet myDataSet = new DataSet();
> > myDataSet.ReadXml =  new StringReader(test.Gogetit());
[quoted text clipped - 6 lines]
> Use what I posted, I did not tell you to try to assign to ReadXml, you
> should call it as shown.
John Saunders - 24 Sep 2006 19:19 GMT
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.