How do I get xml file from webpage to dataset via .NET CF?

M

Me

Hello,

I am currently undertaking development for a Pocket PC 2003 PDA using VB.NET
2003.

I have developed a VB.NET application under the .Net Framework that allows
me to programatically access an xml file from a webpage and load it into my
dataset.

My problem is that I have not been able to figure out how to do so via the
..Net Compact Framework.

Below is a code snipet of the VB.NET code (NON Compact Framework).

Imports System.Xml
Imports System.Data
Imports System.Net

....
strURL = "http://xml.mywebsite.com/" (NOTE: This is NOT an actual website)

myData.ReadXml(strURL)


Can anyone tell me how I may accomplish the same in the .NET Compact
Framework?

Thanks,
Me
 
M

Morten

I have made this in C#, but you should be able to convert it to VB.NET:

public static bool ReadXML(ref DataSet DS)
{
XmlTextReader reader = new
XmlTextReader(http://yourdomain.com/file.xml);

try
{
DS.ReadXml(reader, XmlReadMode.ReadSchema);
}
catch (System.Xml.XmlException error)
{
Debug.WriteLine(error.Message);
return false;
}
return true;
}
 
M

Morten

You could try making a simple xml file like this:

<?xml version="1.0"?>
<Server_Table>
<server>
<host>MyHost</host>
<host_cpu>100</host_cpu>
<gametype>hlds</gametype>
<pid>16053</pid>
<status>WARNING</status>
<port>27015</port>
<cpu>0.0</cpu>
<mem>55M</mem>
<started>Nov 26</started>
</server>
</Server_Table>

Best regards
Morten
 
M

Me

Hi Morten,

Thank you for your response. I'm not sure that I understand your solution.

I'm kinda stuck with having to work with the xml file that is provided for
me on someone else's website. I do not have the option of telling them that
I don't want a schema in the xml. What I am looking for is how to fill a
dataset with their data from their xml webpage that contains schema
information.

Thanks,

Me
 
W

Wolf Logan

the .NET CF doesn't support typed datasets, so I guess the automatic schema
support went out the door, too.

when I load a dataset with a schema under .NET CF, I have to use
ds.ReadXmlSchema() before I try to ds.ReadXml(). if you could break the
schema out separately, you might be able to do that.
 
I

Ilya Tumanov [MS]

Actually, CF runtime supports both XSD schemas for DataSet (XDR schemas are
not supported) and typed DataSets.
However, VS designer does not know how to generate typed DataSet code for
CF.
You can use typed DataSet code from desktop. However, you will have to
remove some unsupported code (e.g. serialization) before you can compile.

CF loads DataSets XML files with schema inside just fine, so you do not
have to use ds.ReadXmlSchema() before ds.ReadXml().
ds.ReadXml() will detect schema in XML file and load it if no schema is
loaded into the DataSet yet.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Wolf Logan" <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
References: <[email protected]>
Subject: Re: How do I get xml file from webpage to dataset via .NET CF?
Lines: 21
Organization: Circle and Cross
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
NNTP-Posting-Host: 69.105.47.116
X-Complaints-To: (e-mail address removed)
X-Trace: newssvr31.news.prodigy.com 1075194497 ST000 69.105.47.116 (Tue, 27 Jan 2004 04:08:17 EST)
NNTP-Posting-Date: Tue, 27 Jan 2004 04:08:17 EST
X-UserInfo1: SCSYQN_@OHSIR\HXEBCBNWX@RJ_XPDLMN@GZ_GYO^RR@ETUCCNSKQFCY@TXDX_WHSVB]ZEJLSNY\
^J[CUVSA_QLFC^RQHUPH[P[NRWCCMLSNPOD_ESALHUK@TDFUZHBLJ\XGKL^NXA\EVHSP[D_C^B_^
JCX^W]CHBAX]POG@SSAZQ\LE[DCNMUPG_VSC@VJM
Date: Tue, 27 Jan 2004 09:08:17 GMT
Path: cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!news-out.cwix.com!newsfeed.cwix.com!prodigy.com!prodigy.com!newsmst
01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr31.news.p
rodigy.com.POSTED!e6cd4876!not-for-mail
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.compactframework:44095
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

the .NET CF doesn't support typed datasets, so I guess the automatic schema
support went out the door, too.

when I load a dataset with a schema under .NET CF, I have to use
ds.ReadXmlSchema() before I try to ds.ReadXml(). if you could break the
schema out separately, you might be able to do that.


Me said:
Thank you for your response. I was able to get this to work under the .NET
Framework. However, I could NOT get it to work under CF. I think the
problem may be that the XML file has a schema. See below:

<ProductInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=http://xml.mydomain.com/schemas3/dev.xsd>

Any suggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top