USZip has a GetInfoByZip(String zipcode) method which retuns an XML
data......
For Example....
USZip u = new USZip();
System.Console.WriteLine(u.GetInfoByZip("49544"));
****OutPut************
<?xml version="1.0" encoding="utf-8" ?>
- <NewDataSet>
- <Table>
<CITY>Grand Rapids</CITY>
<STATE>MI</STATE>
<ZIP>49544</ZIP>
<AREA_CODE>616</AREA_CODE>
<TIME_ZONE>E</TIME_ZONE>
</Table>
</NewDataSet>
this the output which i get if i print it out in console...but i want
this data to be converted in to datatable..and displyed using
GridView......
On Jul 6, 12:52 am, "Aman Sharma" <kajubadam25...@gmail.com> wrote:
> Hi,
>
> Take this data into DataSet and then bind data View using this dataset.
>
When i invoke GetInfoByZip("49544")....it returns...
<?xml version="1.0" encoding="utf-8" ?>
- <NewDataSet>
- <Table>
<CITY>Grand Rapids</CITY>
<STATE>MI</STATE>
<ZIP>49544</ZIP>
<AREA_CODE>616</AREA_CODE>
<TIME_ZONE>E</TIME_ZONE>
</Table>
</NewDataSet> .......i tried storing this in an string array but it
is not working to......iam still thinking on how to take the data into
a dataset???....
charle...@gmail.com
Is your ARM out of control? Let me FIX it for you! (e-mail charle...@gmail.com for the BEST RATES - Mention Code - ARMFIX - WSMB). - WSMB
Enterprise Managed Desktop Computing - By Charles A. Lopez (e-mail charle...@gmail.com - Mention CODE DEWEYADAMS)
Project Management - Professional Software Development - Feasibility Studies as low as $199 USD (email charle...@gmail.com mention CODE MANPOWER7)
DEVELOPERS WANTED - EMAIL WITHIN
Iam not missing something but iam not getting how to convert this XML
file to DataTable.........
when i pass a value in GetInfoByZip("xxx") and tryprinting in console
i am getting an XML(data comes from webservice)..i.e.
<?xml version="1.0" encoding="utf-8" ?>
- <NewDataSet>
- <Table>
<CITY>Grand Rapids</CITY>
<STATE>MI</STATE>
<ZIP>49544</ZIP>
<AREA_CODE>616</AREA_CODE>
<TIME_ZONE>E</TIME_ZONE>
</Table>
</NewDataSet>
but i want this data tobe displayed in datatable.......i tried using
DataTable.Readxml()...but it is not working....iam stucked!!!!
On Jul 7, 4:10 pm, "Charles A. Lopez" <charlesalo...@gmail.com> wrote:
> you have snippets of the code already...
>
> GetInfoByZip("XXXXX")
>
> process the output of that.
>
> Re-Read your original code. You are missing something that is obvious to me.
>
> --
> Charles A. Lopez
> charlesalo...@gmail.com
>
> Is your ARM out of control? Let me FIX it for you! (e-mail
> charlesalo...@gmail.com for the BEST RATES - Mention Code - ARMFIX - WSMB).
> - WSMB
>
> Enterprise Managed Desktop Computing - By Charles A. Lopez (e-mail
> charlesalo...@gmail.com - Mention CODE DEWEYADAMS)
>
> Project Management - Professional Software Development - Feasibility Studies
> as low as $199 USD (email charlesalo...@gmail.com mention CODE MANPOWER7)
>
> DEVELOPERS WANTED - EMAIL WITHIN- Hide quoted text -
>
> - Show quoted text -
If ur method GetInfoByZip() is returning xml as string type, u can do
the following
Dim str As String
Dim strStream As System.IO.StreamReader
Dim ds As DataSet
Dim dt As DataTable
ds = New DataSet
str = GetInfoByZip()
strStream = GetSR(str)
ds = New DataSet
ds.ReadXml(strStream) //Takes StreamReader object as parameter
dt = ds.Tables("Table")
DataGrid1.DataSource = dt
DataGrid1.DataBind()
//Function to convert string to StreamReader object
Public Function GetSR(ByVal Input As String) As StreamReader
GetSR = New StreamReader(New MemoryStream(New
ASCIIEncoding().GetBytes(Input)))
End Function
> > should exist even on the compact framework.- Hide quoted text -
The one thing I dont like about this whole XML straight into the
database is that if the XML changes, your datamodel will need to
change. I would rather write a parser for the XML which returns a
DataTable or DataSet (whichever you like) which then could be pushed
to your DB. If the XML changes, all you need to do is change the
parser.
Then parse the table manually ', Note this is a basic example and you
need to add error checking
Dim TableNode as XmlNodeLIst = Node.SelectNodes("NewDataSet/Table")
Dim DT as new Data.DataTable
For I as integer = 0 to TableNode.ChildNodes.Count -1
DT.Columns.Add(TableNode.ChildNodes(i).Name.ToString)
Next
Dim Row as Data.DataRow = DT.NewRow
For I as integer = 0 to TableNode.ChildNodes.Count -1
Row(TableNode.ChildNodes(i).Name.ToString) =
TableNode.ChildNodes(i).InnerXml.ToString
Next
DT.Rows.Add(Row)
Alexander Higgins
http://alexanderhiggins.com
> > > - Show quoted text -- Hide quoted text -