473,386 Members | 1,674 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,386 software developers and data experts.

xml and sql server

i'v not done a bunch of xml parsing. does anyone have a good resource
showing an example of taking xml data and inserting it into a sql server db
using .net?

any input is appreciated.

tia,

steve
Nov 19 '05 #1
7 1462
i've got a unix system and windows. i'm using web services to synchronize an
oracle db on unix w/ a sql server db on windows. i'm dealing with xml in the
form of records.

does that make sense?
"Jeremy Cowles" <je*************************@asifl.com> wrote in message
news:9I*********************@twister.tampabay.rr.c om...
"steve" <as*@abc.com> wrote in message
news:vg************@corp.supernews.com...
i'v not done a bunch of xml parsing. does anyone have a good resource
showing an example of taking xml data and inserting it into a sql server db
using .net?

any input is appreciated.


Are you trying to use SQLXML (SQL structured as XML), or do you literally
want to dump XML into SQL byte for byte (putting a file into a text

field)?
Jeremy

Nov 19 '05 #2
I have done this in the past and have use DTS to create
the link.

Glenn,
-----Original Message-----
i've got a unix system and windows. i'm using web services to synchronize anoracle db on unix w/ a sql server db on windows. i'm dealing with xml in theform of records.

does that make sense?
"Jeremy Cowles" <je*************************@asifl.com> wrote in messagenews:9I*********************@twister.tampabay.rr. com...
"steve" <as*@abc.com> wrote in message
news:vg************@corp.supernews.com...
> i'v not done a bunch of xml parsing. does anyone have a good resource > showing an example of taking xml data and inserting
it into a sql server db
> using .net?
>
> any input is appreciated.
>
Are you trying to use SQLXML (SQL structured as XML), or do you literally want to dump XML into SQL byte for byte (putting a

file into a textfield)?

Jeremy

.

Nov 19 '05 #3
dts is great but it is an additional step during implementation. i'd like to
stick to using web services and manage the code base all in one spot...plus,
the next guy to come along may not know a thing about dts...then it's back
on me. ;^)

thanks for the thought though.
"Glenn Wilson" <gw***@hotmail.com> wrote in message
news:91****************************@phx.gbl...
I have done this in the past and have use DTS to create
the link.

Glenn,
-----Original Message-----
i've got a unix system and windows. i'm using web

services to synchronize an
oracle db on unix w/ a sql server db on windows. i'm

dealing with xml in the
form of records.

does that make sense?
"Jeremy Cowles" <je*************************@asifl.com>

wrote in message
news:9I*********************@twister.tampabay.rr. com...
"steve" <as*@abc.com> wrote in message
news:vg************@corp.supernews.com...
> i'v not done a bunch of xml parsing. does anyone have a good resource > showing an example of taking xml data and inserting it into a sql server db
> using .net?
>
> any input is appreciated.
>

Are you trying to use SQLXML (SQL structured as XML), or do you literally want to dump XML into SQL byte for byte (putting a

file into a text
field)?

Jeremy

.

Nov 19 '05 #4
well, try this and just add the db functionality.

Private Sub SyncStations(ByVal xml As String)
Dim description As String
Dim id As String
Dim record As String
Dim records() As String
Dim stations As String
stations = getSingleSegment("STATIONS", xml)
records = getMultipleSegments("RECORD", stations)
For Each record In records
id = getSingleSegment("ID", record)
description = getSingleSegment("DESCRIPTION", record)
id = getSegmentValue(id)
description = getSegmentValue(description)
MsgBox(id & vbCrLf & description)
Next
End Sub

Private Function getMultipleSegments(ByVal segment As String, ByVal xml
As String) As String()
Dim pattern As String = "<\s*" & segment & "[^>]*>.*?<\s*/\s*" &
segment & "\s*>"
Dim regExp As New Regex(pattern, RegexOptions.Compiled Or
RegexOptions.ExplicitCapture Or RegexOptions.Singleline Or
RegexOptions.IgnoreCase)
If Not regExp.IsMatch(xml) Then Exit Function
Dim match As Match
Dim result() As String
Dim index As Integer
For Each match In regExp.Matches(xml)
ReDim Preserve result(index)
result(index) = match.Value
index += 1
Next
Return result
End Function

Private Function getSingleSegment(ByVal segment As String, ByVal xml As
String) As String
Dim pattern As String = "<\s*" & segment & "[^>]*>.*?<\s*/\s*" &
segment & "\s*>"
Dim regExp As New Regex(pattern, RegexOptions.Compiled Or
RegexOptions.ExplicitCapture Or RegexOptions.Singleline Or
RegexOptions.IgnoreCase)
If Not regExp.IsMatch(xml) Then Exit Function
Dim match As Match = regExp.Match(xml)
Return match.Value
End Function

Private Function getSegmentValue(ByVal xml As String) As String
Dim pattern As String = "<[^>]*>"
Dim regExp As New Regex(pattern)
If Not regExp.IsMatch(xml) Then Exit Function
Return regExp.Replace(xml, "")
End Function
Nov 19 '05 #5
so i can improve performance by making it slower...;^ )

this is pretty darn simple and i don't have to instanciate node objects all
over the place. i didn't get any hits here about examples or references to
examples...so this is what i came up w/ in lieu of spending time discovering
how to make the xml dom get me the information.

thanks for your generous comments, though, on the state of my mental health.

8 - )

"Jeremy Cowles" <je*************************@asifl.com> wrote in message
news:lZ*******************@twister.tampabay.rr.com ...
That's insane - i think you can seriously improve preformance by using the
built-in XPath search routines (SelectNode and SelectSingleNode). Even if it is slower, it will be MUCH simpler.
"steve" <al*****@jaslkasdfj.com> wrote in message
news:vg************@corp.supernews.com...
well, try this and just add the db functionality.

Private Sub SyncStations(ByVal xml As String)
Dim description As String
Dim id As String
Dim record As String
Dim records() As String
Dim stations As String
stations = getSingleSegment("STATIONS", xml)
records = getMultipleSegments("RECORD", stations)
For Each record In records
id = getSingleSegment("ID", record)
description = getSingleSegment("DESCRIPTION", record)
id = getSegmentValue(id)
description = getSegmentValue(description)
MsgBox(id & vbCrLf & description)
Next
End Sub

Private Function getMultipleSegments(ByVal segment As String, ByVal

xml
As String) As String()
Dim pattern As String = "<\s*" & segment & "[^>]*>.*?<\s*/\s*" &
segment & "\s*>"
Dim regExp As New Regex(pattern, RegexOptions.Compiled Or
RegexOptions.ExplicitCapture Or RegexOptions.Singleline Or
RegexOptions.IgnoreCase)
If Not regExp.IsMatch(xml) Then Exit Function
Dim match As Match
Dim result() As String
Dim index As Integer
For Each match In regExp.Matches(xml)
ReDim Preserve result(index)
result(index) = match.Value
index += 1
Next
Return result
End Function

Private Function getSingleSegment(ByVal segment As String, ByVal xml

As
String) As String
Dim pattern As String = "<\s*" & segment & "[^>]*>.*?<\s*/\s*" &
segment & "\s*>"
Dim regExp As New Regex(pattern, RegexOptions.Compiled Or
RegexOptions.ExplicitCapture Or RegexOptions.Singleline Or
RegexOptions.IgnoreCase)
If Not regExp.IsMatch(xml) Then Exit Function
Dim match As Match = regExp.Match(xml)
Return match.Value
End Function

Private Function getSegmentValue(ByVal xml As String) As String
Dim pattern As String = "<[^>]*>"
Dim regExp As New Regex(pattern)
If Not regExp.IsMatch(xml) Then Exit Function
Return regExp.Replace(xml, "")
End Function

Nov 19 '05 #6

"steve" <as*@abc.com> wrote in message
news:vg************@corp.supernews.com...

thanks for your generous comments, though, on the state of my mental

health.

Any time.

Nov 19 '05 #7
wink.

"Jeremy Cowles" <je*************************@asifl.com> wrote in message
news:Dj*******************@twister.tampabay.rr.com ...

"steve" <as*@abc.com> wrote in message
news:vg************@corp.supernews.com...

thanks for your generous comments, though, on the state of my mental

health.

Any time.

Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Phil | last post by:
I am using a Pascal like language (Wealth-Lab) on W2K and call this server: class HelloWorld: _reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}" _reg_desc_ = "Python Test COM Server"...
6
by: Nathan Sokalski | last post by:
I want to set up SQL Server on Windows XP Pro so that I can use the database capabilities of ASP and IIS. I am probably using some incorrect settings, but I am not sure what they are. Here is what...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
14
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can...
0
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$) { } ...
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
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...
0
Oralloy
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,...
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...

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.