Hi,
I have the following XML file:
<Message>
<MessageInfo MID="ODX95”></MessageInfo>
<Module>
<Invoice number="43562" inv_date="000000">
<Data>
<Name csg="ABC1"></Name>
<PartNumber code="123" quantity="96"></PartNumber>
<Price unit_price="13309.00" total_amount="1277664.00"></Price>
<PartNumber code="345" quantity="24"></PartNumber>
<Price unit_price="20213.00" total_amount="485112.00"></Price>
<PartNumber code="678" quantity="120"></PartNumber>
<Price unit_price="16593.00" total_amount="1991160.00"></Price>
<VAT amount="3753936.00" vat_rate="0.000"></VAT>
<Total total_amount="3753936.00" vat_amount="3753936.00"></Total>
</Data>
</Invoice>
</Module>
</Message>
What I want is that I want to put this data into SQL Table.
exec sp_xml_preparedocument @idoc OUTPUT, @doc
INSERT INTO #Invoices (DocumentNumber, InvoiceNumber, InvoiceDate, PartNumber, Quantity, Price)
SELECT * FROM OPENXML (@idoc, '/Message/Module/Invoice/Data/PartNumber', 1)
WITH (
DocumentNumber varchar(30) '../../../../MessageInfo/@MID',
InvoiceNumber varchar(30) '../../@number',
InvoiceDate varchar(30) '../../@invoice_date',
PartNumber varchar(30) '@code',
Quantity varchar(30) '@quantity',
Price varchar(30) '../Price/@unit_price'
)
EXEC sp_xml_removedocument @idoc
The result I get is the following...
DocumentNumber InvoiceNumber InvoiceDate PartNumber Quantity Price
ODX95 43562 000000 123 96 13309.00
ODX95 43562 000000 345 24 13309.00
ODX95 43562 000000 678 120 13309.00
I am getting always the same Price value. Why is that? And how can I avoid this???
Any ideas???
Thanks....
1 1423
Hi,
I have the following XML file:
<Message>
<MessageInfo MID="ODX95”></MessageInfo>
<Module>
<Invoice number="43562" inv_date="000000">
<Data>
<Name csg="ABC1"></Name>
<PartNumber code="123" quantity="96"></PartNumber>
<Price unit_price="13309.00" total_amount="1277664.00"></Price>
<PartNumber code="345" quantity="24"></PartNumber>
<Price unit_price="20213.00" total_amount="485112.00"></Price>
<PartNumber code="678" quantity="120"></PartNumber>
<Price unit_price="16593.00" total_amount="1991160.00"></Price>
<VAT amount="3753936.00" vat_rate="0.000"></VAT>
<Total total_amount="3753936.00" vat_amount="3753936.00"></Total>
</Data>
</Invoice>
</Module>
</Message>
What I want is that I want to put this data into SQL Table.
exec sp_xml_preparedocument @idoc OUTPUT, @doc
INSERT INTO #Invoices (DocumentNumber, InvoiceNumber, InvoiceDate, PartNumber, Quantity, Price)
SELECT * FROM OPENXML (@idoc, '/Message/Module/Invoice/Data/PartNumber', 1)
WITH (
DocumentNumber varchar(30) '../../../../MessageInfo/@MID',
InvoiceNumber varchar(30) '../../@number',
InvoiceDate varchar(30) '../../@invoice_date',
PartNumber varchar(30) '@code',
Quantity varchar(30) '@quantity',
Price varchar(30) '../Price/@unit_price'
)
EXEC sp_xml_removedocument @idoc
The result I get is the following...
DocumentNumber InvoiceNumber InvoiceDate PartNumber Quantity Price
ODX95 43562 000000 123 96 13309.00
ODX95 43562 000000 345 24 13309.00
ODX95 43562 000000 678 120 13309.00
I am getting always the same Price value. Why is that? And how can I avoid this???
Any ideas???
Thanks....
Hi, I guess you need two modifications:
1. Data set: I belive that the closing tag for <PartNumber> is misplaced, move them to behind each </Price> tags like this: -
<PartNumber code="123" quantity="96">
-
<Price unit_price="13309.00" total_amount="1277664.00"></Price></PartNumber>
-
<PartNumber code="345" quantity="24">
-
<Price unit_price="20213.00" total_amount="485112.00"></Price></PartNumber>
-
<PartNumber code="678" quantity="120">
-
<Price unit_price="16593.00" total_amount="1991160.00"></Price></PartNumber>
-
2. change the SELECT to: -
SELECT * FROM OPENXML (@idoc, '/Message/Module/Invoice/Data/PartNumber', 1)
-
WITH (
-
DocumentNumber varchar(30) '../../../../MessageInfo/@MID',
-
InvoiceNumber varchar(30) '../../@number',
-
InvoiceDate varchar(30) '../../@invoice_date',
-
PartNumber varchar(30) '@code',
-
Quantity varchar(30) '@quantity',
-
Price varchar(30) 'Price/@unit_price'
-
)
-
(i.e. remove the '../' string from the 'Price' field).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: CHIN |
last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i
cant find the solution !! )
I have to upload a file to an external site, so, i made a .vbs file , that
logins to...
|
by: Lamberti Fabrizio |
last post by:
Hi all,
I've to access to a network file from an asp pages.
I've red a lot of things on old posts and on Microsoft article but I can't
still solve my problem.
I've got two server inside the...
|
by: BW |
last post by:
I am creating an upload/download function for an extranet site. Files will
be uploaded to directory based upon the users login and associated project.
The function works as long as I use "c:\Temp"...
|
by: Jen |
last post by:
I'm using Microsoft's own VB.NET FTP Example:
http://support.microsoft.com/default.aspx?scid=kb;en-us;832679
I can get the program to create directories, change directories, etc.,
but I can't...
|
by: Sarah |
last post by:
I need to access some data on a server. I can access it directly using UNC
(i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network
drive resource (S:\Path\FileName).
Here is my...
|
by: Matt Jensen |
last post by:
Howdy
I've got a rather strange issue occuring.
I used forms based .NET authentication, although I'm also setting some
session variables when people login.
However, I've found when people use...
|
by: CGW |
last post by:
I asked the question yesterday, but know better how to ask it, today:
I'm trying to use the File.Copy method to copy a file from a client to
server (.Net web app under IIS ). It looks to me that...
|
by: laredotornado |
last post by:
Hi,
I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed
using Apache's apxs and the php library was installed to
/usr/local/php. However, when I set my "error_reporting"...
|
by: Vlad |
last post by:
I am having problems using the file.create method within a function
that is called when looping through an array of filepaths.
If I call my function with a hardcoded file path --C:\Temp.txt the...
|
by: premprakashbhati |
last post by:
hi, good evening..
i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button()
here is the code ...its work fine...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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: 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,...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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,...
| |