question

Peter001 avatar image
Peter001 asked

Unable to parse xml document

[link text][1]Hello Techie, may any one please help me with step, how can i move the xml data to sql table. i tried using SSIS and c#, but not able to parse the xml. **file attached herewith** appreciate your help. Thanks, Pete [1]: /storage/temp/ 3097-xml.txt
xmlparsing
xml.txt (1.3 KiB)
1 comment
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thank You Gents.
0 Likes 0 ·
Grant Fritchey avatar image
Grant Fritchey answered
Here are the basics. You can expand from here. I did have to modify your XML to add a ROOT: DECLARE @DociD INT, @XML NVARCHAR(MAX) = ' 2 Professional Grade 816-8130 2 Professional Grade 816-8130 2 Professional Grade 816-8130 '; EXEC sys.sp_xml_preparedocument @DociD OUTPUT, @XML; SELECT * FROM OPENXML(@DociD,'/root/App',2) WITH (appaction CHAR(1) '@action',id INT '@id',BaseVehicleID INT './BaseVehicle/@id');
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kev Riley avatar image
Kev Riley answered
Your XML is not complete. At the very end there is the end tag ``, so you need a starting tag of `` at the beginning of the document. After that it will be recognised as well-formed XML. Ho to get it into a table is a different question - you would have to define the table structure as I don't know ho you want to handle the various elements
1 comment
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Ah, I didn't copy the whole XML doc. Yeah, having would work instead of the modification I did in adding . I just assumed that it was parsing the XML that was hard, not knowing how to do the INSERT operation.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.