Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Script to close XML tags?

Author  Topic 

alemos
Starting Member

16 Posts

Posted - 2008-10-29 : 06:35:07
Hi everyone,

I have been trying to find either a regular expression pattern or some script to help me with badly written XML files. I have a parser that gets XML files and imports them into tables. It is a long script because I have to use regular expressions (I can post the scripts I got online for this) to correct things like including quotes in string parameters (example <tag name=abc> to <tag name="abc">) and so on.

But I have run into a problem. I cannot write an appropriate REGEX expression (I am not realy skilled in Regular Expressions) or a script that finds if the xml file's tags all have closing tags.

Anyone ever done that in T-SQL? It has to be part of a Stored Procedure. I am using MSSQL 2005.

Thanks everyone.

Aécio Lemos
http://www.vlsweb.com.br
O primeiro provedor de hospedagem gerenciada do Brasil

alemos
Starting Member

16 Posts

Posted - 2008-10-29 : 07:59:11
Oh, BTW, some files have the closing tags and others don't so I do have to check if they exist. I just tried a REGEX, but I could not make it work. I really have to learn REGEX!!! :D

Aécio Lemos
http://www.vlsweb.com.br
O primeiro provedor de hospedagem gerenciada do Brasil
Go to Top of Page

alemos
Starting Member

16 Posts

Posted - 2008-10-30 : 20:51:50
So, nobody able to help me here? Dang! :) I think I stumped the SQL Gurus!!! Yeah, I am stumped, too. I have been trying for days to make this work, and I am almost giving up and returning the client's money! Wow, first time in 20 years I will be defeated by a program! Is it even possible?

thanks anyway everyone.

Aécio Lemos
http://www.vlsweb.com.br
O primeiro provedor de hospedagem gerenciada do Brasil
Go to Top of Page

cvraghu
Posting Yak Master

187 Posts

Posted - 2008-10-31 : 01:21:30
Ending tags are missing for only empty nodes or even nodes with children?

I can only think of a string manipulation solution!
Go to Top of Page

alemos
Starting Member

16 Posts

Posted - 2008-10-31 : 06:48:34
Some of the nodes have children. An example:

<head>
<title>Some title</title>
<duration time="30"></duration>
</head>
<fields>
<f enc="AVI"></f>
<f framerate="30"></f>
</fields>

That is what it SHOULD look like. But this is what some of the files look like

<head>
<title>Some title</title>
<duration time="30"></duration>
</head>
<fields>
<f enc="AVI">
<f framerate="30">
</fields>

where the <f> fields have no closing tag.

Any ideas?

Aécio Lemos
http://www.vlsweb.com.br
O primeiro provedor de hospedagem gerenciada do Brasil
Go to Top of Page
   

- Advertisement -