How should one import data that is stored in the following fashion?
<Restaurants>
- <Restaurant>
<Category>American Restaurants</Category>
<Name>APPLEBEES</Name>
<Address>1273 HOOKSETT RD, HOOKSETT, NH 03106</Address>
<StreetAddress>1273 HOOKSETT RD</StreetAddress>
<City>HOOKSETT</City>
<State>NH</State>
<Zip>03106</Zip>
<Phone>(603) 000-0000</Phone>
<Lon>-71.4363</Lon>
<Lat>43.0484</Lat>
</Restaurant>
- <Restaurant>
<Category>American Restaurants</Category>
<Name>APPLEBEES</Name>
<Address>14 MANCHESTER RD, DERRY, NH 03038</Address>
<StreetAddress>14 MANCHESTER RD</StreetAddress>
<City>DERRY</City>
<State>NH</State>
<Zip>03038</Zip>
<Phone>(603) 000-0000</Phone>
<Lon>-71.3298</Lon>
<Lat>42.8958</Lat>
</Restaurant>
</Restaurants> 11 1607
Hi, http://msdn.microsoft.com/library/de...mlfromfile.asp
Ken
-------------------------
"pmclinn" <pe***@mclinn.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
How should one import data that is stored in the following fashion?
<Restaurants>
- <Restaurant>
<Category>American Restaurants</Category>
<Name>APPLEBEES</Name>
<Address>1273 HOOKSETT RD, HOOKSETT, NH 03106</Address>
<StreetAddress>1273 HOOKSETT RD</StreetAddress>
<City>HOOKSETT</City>
<State>NH</State>
<Zip>03106</Zip>
<Phone>(603) 000-0000</Phone>
<Lon>-71.4363</Lon>
<Lat>43.0484</Lat>
</Restaurant>
- <Restaurant>
<Category>American Restaurants</Category>
<Name>APPLEBEES</Name>
<Address>14 MANCHESTER RD, DERRY, NH 03038</Address>
<StreetAddress>14 MANCHESTER RD</StreetAddress>
<City>DERRY</City>
<State>NH</State>
<Zip>03038</Zip>
<Phone>(603) 000-0000</Phone>
<Lon>-71.3298</Lon>
<Lat>42.8958</Lat>
</Restaurant>
</Restaurants>
pmclinn,
This is a dataset so
\\\
dim ds as new dataset
ds.readXML("path to the file")
datagrid1.datasource = ds.tables(0)
///
Will show it in a datagrid.
I hope this helps?
Cor
"pmclinn" <pe***@mclinn.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com... How should one import data that is stored in the following fashion?
<Restaurants> - <Restaurant> <Category>American Restaurants</Category> <Name>APPLEBEES</Name> <Address>1273 HOOKSETT RD, HOOKSETT, NH 03106</Address> <StreetAddress>1273 HOOKSETT RD</StreetAddress> <City>HOOKSETT</City> <State>NH</State> <Zip>03106</Zip> <Phone>(603) 000-0000</Phone> <Lon>-71.4363</Lon> <Lat>43.0484</Lat> </Restaurant> - <Restaurant> <Category>American Restaurants</Category> <Name>APPLEBEES</Name> <Address>14 MANCHESTER RD, DERRY, NH 03038</Address> <StreetAddress>14 MANCHESTER RD</StreetAddress> <City>DERRY</City> <State>NH</State> <Zip>03038</Zip> <Phone>(603) 000-0000</Phone> <Lon>-71.3298</Lon> <Lat>42.8958</Lat> </Restaurant> </Restaurants>
Depends on import to what really...
Import implies to database to my mind.
Just in case that's what you mean.
If you're talking sql server then sqlxmlbulkload will import big xml files
and you could use a vbscript DTS to do so.
Otherwise, you already have a couple answers like xmlreader.
Here is the code that wrote the file:
'ExportArray is an arraylist
'and Details is a structure
'I'm taking the structures that have been saved into the arraylist and
then exporting them using the textwriter. See comments below code:
'_______________________Write Code
Dim mywriter As System.Xml.XmlTextWriter
mywriter = New System.Xml.XmlTextWriter("c:\NH.xml", Nothing)
With mywriter
.Indentation = 4
.IndentChar = " "
.Formatting = .Indentation
.WriteStartDocument()
.WriteComment("NH Listing")
.WriteStartElement("Restaurants")
For i As Integer = 0 To ExportArray.Count - 1
.WriteStartElement("Restaurant")
.WriteElementString("Category", CType(ExportArray(i),
Details).strCat)
.WriteElementString("Name", CType(ExportArray(i),
Details).strName)
.WriteElementString("Address", CType(ExportArray(i),
Details).strAddress)
.WriteElementString("StreetAddress",
CType(ExportArray(i), Details).strStreetAddress)
.WriteElementString("City", CType(ExportArray(i),
Details).strCityName)
.WriteElementString("State", CType(ExportArray(i),
Details).strStateName)
.WriteElementString("Zip", CType(ExportArray(i),
Details).strZip)
.WriteElementString("Phone", CType(ExportArray(i),
Details).strPhone)
.WriteElementString("Lon", CType(ExportArray(i),
Details).Lon)
.WriteElementString("Lat", CType(ExportArray(i),
Details).Lat)
.WriteEndElement()
Next
.WriteEndElement()
.WriteEndDocument()
End With
'End Write Code
'Sample output:
<?xml version="1.0" ?>
- <!-- NH Listing
-->
- <Restaurants>
- <Restaurant>
<Category>American Restaurants</Category>
<Name>APPLEBEES</Name>
<Address>1273 HOOKSETT RD, HOOKSETT, NH 03106</Address>
<StreetAddress>1273 HOOKSETT RD</StreetAddress>
<City>HOOKSETT</City>
<State>NH</State>
<Zip>03106</Zip>
<Phone>(603) 627-3000</Phone>
<Lon>-71.4363</Lon>
<Lat>43.0484</Lat>
</Restaurant>
- <Restaurant>
<Category>American Restaurants</Category>
<Name>APPLEBEES</Name>
<Address>14 MANCHESTER RD, DERRY, NH 03038</Address>
<StreetAddress>14 MANCHESTER RD</StreetAddress>
<City>DERRY</City>
<State>NH</State>
<Zip>03038</Zip>
<Phone>(603) 432-5600</Phone>
<Lon>-71.3298</Lon>
<Lat>42.8958</Lat>
</Restaurant>
'End sample output....'truncated sample
'----------------------More comments
I have found that I can import the enteries using the code below but I
want to refrence by type. So in the example below I refrence the
item(0) but I would rather refrence it as Category...Name...Address....
'---------------------My code right now
Begin read code:
Dim s As New Details
Dim al As New ArrayList
Try
Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode
'Create the XML Document
m_xmld = New XmlDocument
'Load the Xml file
m_xmld.Load("C:\NH.xml")
'Get the list of name nodes
m_nodelist = m_xmld.SelectNodes("/Restaurants/Restaurant")
'Loop through the nodes
For Each m_node In m_nodelist
s.strCat = m_node.ChildNodes.Item(0).InnerText
s.strName = m_node.ChildNodes.Item(1).InnerText
Console.Write(s.strCat)
Next
Catch errorVariable As Exception
'Error trapping
Console.Write(errorVariable.ToString())
End Try
'Any direction would be appreciated. Thanks
Peter,
What is the reason that you use that expensive code while I showed that it
can be done in two lines?
(Which I even tested for you by the way with your file)
Cor
If I read the data from the grid won't that cost more in the long run?
Cor Ligthert wrote: Peter,
What is the reason that you use that expensive code while I showed
that it can be done in two lines? (Which I even tested for you by the way with your file)
Cor
Peter,
You can as well use the viewstate and send it with the page.
However how do you want to read it from the grid.
I could not succeed in that?
Cor
"pmclinn" <pe***@mclinn.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com... If I read the data from the grid won't that cost more in the long run?
I'm still confused as to what you're trying to accomplish.
You want to get the data out the file into some program.
To do what?
To just display it?
I guess not.
--
Regards,
Andy O'Neill
The data is stored in XML format simply because of re-usablity factors.
Everynight I run a program that finds all the current restaurant
listings and there GPS coordinates. This data is then pushed up to a
remote SQL Server, where I will have to preform distance and positional
operations on the data. So transfering the data to the grid is
currently out of the questions.
So I was hoping to be able to select 'typed elements' by name for code
readiblity reasons.
"pmclinn" <pe***@mclinn.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com... The data is stored in XML format simply because of re-usablity factors. Everynight I run a program that finds all the current restaurant listings and there GPS coordinates. This data is then pushed up to a remote SQL Server, where I will have to preform distance and positional operations on the data. So transfering the data to the grid is currently out of the questions.
So I was hoping to be able to select 'typed elements' by name for code readiblity reasons.
You still haven't told us why the techniques suggested are no good to you.
So at this point I can only ask the same question again....
From this I get you want the data from one server to be used on another
server.
It's a batch over-night process.
Correct?
So my next question.
What's wrong with my initial suggestion:
Load it into a table using sqlxmlbulkload.
Use a DTS package scheduled to run nightly.
Stick it in a table.
Once you have it in your remote database you can do whatever you want with
the data there.
--
Regards,
Andy O'Neill
My provider [Godaddy.com] does not give me access to the DTS
packages unfortunately. I'm using a hosted plan and not a dedicated
server for obvious cost reasons. Let me put it this way, Godaddy only
allows end users to push content up via web forms and/or through a
pethetic csv. loader utility that crashes half way through most
uploads.
Yes. This is a nightly batch run.
The process only imports new addresses and account information so I
finally ended up creating a password protected directory that allows me
to push the records via an asp form into the database. LOL.
Definately not an optimum situation.
I'm just trying to get the site up and running this month to show to
prospective clients. If the test goes well then I'll have funding to
lease a dedicated server.
-Peter This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dariusz |
last post by:
Below is part of a code I have for a database. While the database table is
created correctly (if it doesn't exist), and data is input correctly into
the database when executed, I have a problem...
|
by: Andy |
last post by:
Hi,
In the code below (not pretty I know but it's an early version :-P) I'm
having problems reading the data object back in. If I move the reading
code to immediately after the section where it...
|
by: Magnus |
last post by:
allrite folks, got some questions here...
1) LAY-OUT OF REPORTS
How is it possible to fundamentaly change the lay-out/form of a report in
access? I dont really know it that "difficult", but...
|
by: KevinD |
last post by:
assumption: I am new to C and old to COBOL
I have been reading a lot (self teaching) but something is not sinking
in with respect to reading a simple file - one record at a time.
Using C, I am...
|
by: arne.muller |
last post by:
Hello,
I've come across some problems reading strucutres from binary files.
Basically I've some strutures
typedef struct {
int i;
double x;
int n;
double *mz;
|
by: Tyler |
last post by:
Hello All:
After trying to find an open source alternative to Matlab (or IDL), I
am currently getting acquainted with Python and, in particular SciPy,
NumPy, and Matplotlib. While I await the...
|
by: blazedaces |
last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
|
by: Shark |
last post by:
Hi,
I need a help. My application reads data from COM port, this data is then
parsed and displyed on:
1. two plotters
2. text box.
I'm using Invoke method to update UI when new data is...
|
by: swetha |
last post by:
HI Every1,
I have a problem in reading a binary file.
Actually i want a C program which reads in the data from a file which
is in binary format and i want to update values in it.
The file...
|
by: efrenba |
last post by:
Hi,
I came from delphi world and now I'm doing my first steps in C++. I'm
using C++builder because its ide is like delphi although I'm trying to
avoid the vcl.
I need to insert new features...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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...
|
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,...
|
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...
| |