TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ed Tshuma
NA
249
1.1k
How do i resolve incorrect syntax error when parsing an XML
Aug 28 2019 5:22 AM
I have a program to import data from an XML file into a SQL Server table. I am using the project by @Altafi Ansari here https://www.c-sharpcorner.com/article/xml-file-to-sql-database/. When i debug the program i get an "Incorrect syntax near 'TRANSACTION'" error as the flow starts creating the table . My observation are that the program can interpret the EXPORT_HEADER tag but the TRANSACTION tag is not being interpreted. I have attached my XML file here for clarity.
My XML is structured as below :
<?
xml
version
=
"1.0"
encoding
=
"utf-16"
?>
<
EXPORT_HEADER
xmlns
=
"http://www.sir.com/SFI/Export/GL_Export/20051005"
xmlns:xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation
=
"http://www.sir.com/SFI/Export/GL_Export/20051005 GL_EXPORT.xsd"
total_transactions
=
"4616"
total_accnts
=
"2000"
>
<
TRANSACTION
business_type_code
=
"DIRECT"
term
=
"NB"
/>
<
TRANSACTION
business_type_code
=
"DIRECT"
term
=
"NB"
/>
</
EXPORT_HEADER
>
However when i use the TRANSACTION tag section which contains the actual data i want to commit im getting the syntax error above:
DataSet DS =
new
DataSet();
DS.ReadXml(XMlFile);
DataTable dt = DS.Tables[1];
if
(dt.Columns.Count == 0)
dt.ReadXmlSchema(XMlFile);
dt.ReadXml(XMlFile);
As a check i tried using EXPORT_HEADER section and the data in the header is successfully committed and table also created:
DataSet DS =
new
DataSet();
DS.ReadXml(XMlFile);
DataTable dt = DS.Tables[0];
if
(dt.Columns.Count == 0)
dt.ReadXmlSchema(XMlFile);
dt.ReadXml(XMlFile);
Attachment:
GL_Export_54_201907081053.zip
Reply
Answers (
1
)
ajax c# html jquery
How to Check Checkbox , when selected on webgrid in mvc?