Boring parsing multiple fields from the same namespace...
  Home FAQ Contact Sign in
microsoft.public.sqlserver.xml only
 
Advanced search
POPULAR GROUPS

more...

microsoft.public.sqlserver.xml Profile…
 Up
Boring parsing multiple fields from the same namespace...         


Author: SammyBar
Date: Sep 12, 2008 10:23

Hi all,

I'm parsing an xml data type to import those data into a table. My current
approach is:

Declare @xDoc Xml
Set @xDoc = some xml
Set @sReferenciaID = @xDoc.value('declare namespace
ns="http://Homex.WS.FacturacionElectronica.DataTypes/2007/12";
/ns:OrdenAceptacion/ns:Addenda/ns:ReferenciaID)[1]', 'varchar(max)')
Set @sAlmacenCodigo = @xDoc.value('declare namespace
ns="http://Homex.WS.FacturacionElectronica.DataTypes/2007/12";
(/ns:OrdenAceptacion/ns:Addenda/ns:AlmacenCodigo)[1]', 'varchar(max)')
...

But there are dozens of such fields! It is a little boring to type all that
stuff, specially the namespace over and over again. May be is it another
more compact way to write this?

I feel should be something like:
Show full article (1.31Kb)
2 Comments
Re: Boring parsing multiple fields from the same namespace...         


Author: Martin Honnen
Date: Sep 13, 2008 03:45

SammyBar wrote:
> Hi all,
>
> I'm parsing an xml data type to import those data into a table. My current
> approach is:
>
> Declare @xDoc Xml
> Set @xDoc = some xml
> Set @sReferenciaID = @xDoc.value('declare namespace
> ns="http://Homex.WS.FacturacionElectronica.DataTypes/2007/12";
> /ns:OrdenAceptacion/ns:Addenda/ns:ReferenciaID)[1]', 'varchar(max)')
> Set @sAlmacenCodigo = @xDoc.value('declare namespace
> ns="http://Homex.WS.FacturacionElectronica.DataTypes/2007/12";
> (/ns:OrdenAceptacion/ns:Addenda/ns:AlmacenCodigo)[1]', 'varchar(max)')
> ...
>
> But there are dozens of such fields! It is a little boring to type all that
> stuff, specially the namespace over and over again. May be is it another
> more compact way to write this?
Show full article (1.25Kb)
no comments
Re: Boring parsing multiple fields from the same namespace...         


Author: SammyBar
Date: Sep 15, 2008 17:10

Thanks Martin, it is just what I was looking for!

"Martin Honnen" escribi
no comments

RELATED THREADS
SubjectArticles qty Group
Comparing Data/Time field with Integer field (both storing time information)?comp.databases.ms-access ·