473,396 Members | 1,892 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.

parse xml file insert into database

This is what i'm currently doing, but what I would like is parse the xml only get phone, cellphone, name & userid.

I'm getting a http stream xml file: sample below
Expand|Select|Wrap|Line Numbers
  1. <root>
  2. <bhcontact name="john doe" userid="123">
  3.   <address>my address here</address>
  4.  <phone>123-456-7890</phone>
  5.   <cellphone>123-456-7888</cellphone>
  6.    <state>GA</state>
  7.    <zip>12345</zip>
  8. </bhcontact>
  9. </root>
  10.  
  11.  
  12. DataSet xmlDS = new DataSet();
  13. DataRow dataRow;
  14. DataSet dbDS = new DataSet("contactxml");
  15. xmlDS.ReadXml(new StringReader("XML STRING HERE--see above"));
  16. trcCon.Open();
  17.             SqlDataAdapter trcDA = new SqlDataAdapter("Select * from clientcontact where 1=2", trcCon);
  18.             trcDA.Fill(dbDS, "contactxml");
  19.             foreach(DataRow drow in xmlDS.Tables[0].Rows)
  20.             {
  21.                 dataRow = dbDS.Tables[0].NewRow();
  22.                 for(int i=1; i <xmlDS.Tables[0].Columns.Count; i++)
  23. {
  24.  dataRow[i] = drow[i];
  25. }
  26. dbDS.Tables[0].Rows.Add(dataRow);
  27.                 SqlCommandBuilder trcCmd = new SqlCommandBuilder(trcDA);
  28.                 trcDA.Update(dbDS, "contactxml");
  29.  
  30.                 trcCon.Close();
  31.  
Feb 15 '08 #1
1 1653
kenobewan
4,871 Expert 4TB
One way may be to alter your select statement. HTH.
Feb 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Salim | last post by:
Hi people, keep getting this errorParse error: parse error, unexpected T_STRING in order_fns.php line 91. the code is below for the file and I've indicated line 91 <?php function...
6
by: Ehartwig | last post by:
I recently created a script for user verification, solved my emailing issues, and then re-created the script in order to work well with the new PHP 5 that I installed on my server. After...
11
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a...
5
by: liming | last post by:
Hi all, I have to parse two text files on a weekly basis. Each range from 300kb to 1mb in total. Each text file has 5 columns (name,id, dollar, startdate,enddate), everytime, a) I need to...
14
by: Rob Meade | last post by:
Hi all, I'm working on a project where there are just under 1300 course files, these are HTML files - my problem is that I need to do more with the content of these pages - and the thought of...
5
by: portCo | last post by:
Hi there, I am re-organizing the database. We used to have field 'names' in our table for our first name and last name. However, I want to have those names in different field. FYI, I have two...
3
by: basswhizz | last post by:
Hi everyone im a high school student and I'm having trouble with one of my projects could you please help!! I'm getting this error message. Parse error: syntax error, unexpected...
0
by: destiny1 | last post by:
Hi, I am to parse all the queries from a code file and insert all the queries into database. I am using the following query to insert into DB: cursor.execute("insert into tab_query_analyser...
9
by: Gilles Ganault | last post by:
Hello I googled for samples, but I'd like to make sure there's no simpler way to parse tab-separated data read from a web page, before I can save them into a database: <?php $input =...
8
by: NuclearIce | last post by:
I have looked at literally hundreds of ways to parse but I do not know how to do it myself I just don't understand it really. I have a word list text file like this abbreviation abuser...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.