×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Help With Parsing XML File into SQL Server With Hyphens in Element Names

Help With Parsing XML File into SQL Server With Hyphens in Element Names

Help With Parsing XML File into SQL Server With Hyphens in Element Names

(OP)
Hi,

I am fairly new to working with XML files and schemas etc. I have got a file which we receive daily that needs to be imported into an SQL Server database. I have set up an xsd file to import the data and it works fine for most of the elements, however, there are several elements that have a hyphen in the element name. Whenever I try to run the script to import the file it generates an error code 80004005 "schema: invalid value for column" and this only happens when I add any of the elements with a hyphen in the name.

The source file is around 2gb and it's not possible to get the elements changed so I need to find a way to handle the hyphens during the import. I considered trying to do a find and replace on the field names in the raw file before importing but it is so big that it is not really practical to do this as it takes forever to load and navigate.

If anybody has any ideas on how I can get around it I would be really grateful as I've spent a couple of days looking at this and really can't find a way around it and there doesn't seem to be anything similar when I have tried googling the problem. If anybody needs and further information or screenshots etc then please let me know.

Thanks for reading

RE: Help With Parsing XML File into SQL Server With Hyphens in Element Names

The simplest approach would be XSLT. Here is a short tutorial.

Then, you need to find the appropriate transform example on which to base your transform. Renaming elements is rather simple. Here is an example.

Be sure to come back here to ask questions...

Tom Morrison
Consultant

RE: Help With Parsing XML File into SQL Server With Hyphens in Element Names

but have you've tried declaring the character as an entity?

you would in your case put this under the xml header:

CODE --> xml

<!ENTITY - "&#45;"> 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close