问:
Does not show data when loading XML on sql server
I have an XML and I want it to look like a table in sql, this is the structure

```<code>declare @xml xml =
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
  <GenerateReportResponse
    xmlns="http://tempuri.org">
     <GenerateReportResult>
        <Data>
           <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
              <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Table" msdata:UseCurrentLocale="true">
                 <xs:complexType>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                       <xs:element name="Table">
                          <xs:complexType>
                             <xs:sequence>
                                <xs:element name="Registro" type="xs:long" minOccurs="0"/>
                                <xs:element name="Campania" type="xs:string" minOccurs="0"/>
                                <xs:element name="Instancia" type="xs:string" minOccurs="0"/>
                                <xs:element name="Intentos" type="xs:int" minOccurs="0"/>
                                <xs:element name="Duración_x0020_Total" type="xs:int" minOccurs="0"/>
                                <xs:element name="Duración_x0020_Preview" type="xs:int" minOccurs="0"/>
                                <xs:element name="Duración_x0020_Llamada" type="xs:int" minOccurs="0"/>
                                <xs:element name="Estado_x0020_Registro" type="xs:string" minOccurs="0"/>
                                <xs:element name="Estado_x0020_de_x0020_la_x0020_Última_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Último_x0020_Teléfono_x0020_Marcado" type="xs:string" minOccurs="0"/>
                                <xs:element name="Bonificación_x0020_de_x0020_la_x0020_Última_x0020_Gestión" type="xs:int" minOccurs="0"/>
                                <xs:element name="Fecha_x0020_Hora_x0020_Agenda" type="xs:dateTime" minOccurs="0"/>
                                <xs:element name="Teléfono_x0020_Agenda" type="xs:string" minOccurs="0"/>
                                <xs:element name="Gestión_x0020_Nivel_x0020_1" type="xs:string" minOccurs="0"/>
                                <xs:element name="Gestión_x0020_Nivel_x0020_2" type="xs:string" minOccurs="0"/>
                                <xs:element name="Gestión_x0020_Nivel_x0020_3" type="xs:string" minOccurs="0"/>
                                <xs:element name="Gestión_x0020_Nivel_x0020_4" type="xs:string" minOccurs="0"/>
                                <xs:element name="Gestión_x0020_Nivel_x0020_5" type="xs:string" minOccurs="0"/>
                                <xs:element name="Fecha_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Hora_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Resultado" type="xs:string" minOccurs="0"/>
                                <xs:element name="Observaciones" type="xs:string" minOccurs="0"/>
                                <xs:element name="Usuario_x0020_Última_x0020_Modificación" type="xs:string" minOccurs="0"/>
                                <xs:element name="Nombres_x0020_Usuario_x0020_Última_x0020_Modificación" type="xs:string" minOccurs="0"/>
                                <xs:element name="Apellidos_x0020_Usuario_x0020_Última_x0020_Modificación" type="xs:string" minOccurs="0"/>
                                <xs:element name="Usuario_x0020_Asignado" type="xs:string" minOccurs="0"/>
                                <xs:element name="Nombres_x0020_Usuario_x0020_Asignado" type="xs:string" minOccurs="0"/>
                                <xs:element name="Apellidos_x0020_Usuario_x0020_Asignado" type="xs:string" minOccurs="0"/>
                                <xs:element name="Usuario_x0020_Última_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Nombres_x0020_Usuario_x0020_Última_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Apellidos_x0020_Usuario_x0020_Última_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="EtiquetaCallCopyUser3" type="xs:string" minOccurs="0"/>
                                <xs:element name="EtiquetaCallCopyUser4" type="xs:string" minOccurs="0"/>
                                <xs:element name="EtiquetaCallCopyUser10" type="xs:string" minOccurs="0"/>
                                <xs:element name="EtiquetaCallCopyUser11" type="xs:string" minOccurs="0"/>
                                <xs:element name="EtiquetaCallCopyUser12" type="xs:string" minOccurs="0"/>
                                <xs:element name="EtiquetaCallCopyUser13" type="xs:string" minOccurs="0"/>
                                <xs:element name="Fecha_x0020_Creación" type="xs:string" minOccurs="0"/>
                                <xs:element name="Hora_x0020_Creación" type="xs:string" minOccurs="0"/>
                                <xs:element name="Grupo_x0020_Inicia_x0020_Última_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Grupo_x0020_Finaliza_x0020_Última_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Origen" type="xs:string" minOccurs="0"/>
                                <xs:element name="Versión_x0020_Encuesta" type="xs:string" minOccurs="0"/>
                                <xs:element name="Fecha_x0020_Versión_x0020_Encuesta" type="xs:string" minOccurs="0"/>
                                <xs:element name="Hora_x0020_Versión_x0020_Encuesta" type="xs:string" minOccurs="0"/>
                                <xs:element name="Versión_x0020_Estructura_x0020_de_x0020_Carga" type="xs:string" minOccurs="0"/>
                                <xs:element name="Fecha_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga" type="xs:string" minOccurs="0"/>
                                <xs:element name="Hora_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga" type="xs:string" minOccurs="0"/>
                                <xs:element name="Estado_x0020_QA" type="xs:string" minOccurs="0"/>
                                <xs:element name="Grupo_x0020_Negocio" type="xs:string" minOccurs="0"/>
                                <xs:element name="Grupo_x0020_Llamada" type="xs:string" minOccurs="0"/>
                                <xs:element name="Tipo_x0020_de_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="CodCliente" type="xs:string" minOccurs="0"/>
                                <xs:element name="Nombre_x0020_Establecimiento" type="xs:string" minOccurs="0"/>
                                <xs:element name="Responsable_x0020_Negocio" type="xs:string" minOccurs="0"/>
                                <xs:element name="Tipo_x0020_de_x0020_Cliente_x0020__x0028_D_x002F_E_x0029_" type="xs:string" minOccurs="0"/>
                                <xs:element name="ABC" type="xs:string" minOccurs="0"/>
                                <xs:element name="Sector" type="xs:string" minOccurs="0"/>
                                <xs:element name="Gerencia" type="xs:string" minOccurs="0"/>
                                <xs:element name="Frecuencia_x0020_de_x0020_llamada" type="xs:string" minOccurs="0"/>
                                <xs:element name="Telefono_x0020_Movil_x0020_1" type="xs:string" minOccurs="0"/>
                                <xs:element name="Telefono_x0020_Movil_x0020_2" type="xs:string" minOccurs="0"/>
                                <xs:element name="Telefono_x0020_Fijo_x0020_1" type="xs:string" minOccurs="0"/>
                                <xs:element name="Telefono_x0020_Fijo_x0020_2" type="xs:string" minOccurs="0"/>
                                <xs:element name="Telefono_x0020_Adicional_x0020__x0028_M_x0020_o_x0020_F_x0029_" type="xs:string" minOccurs="0"/>
                                <xs:element name="Ciudad" type="xs:string" minOccurs="0"/>
                                <xs:element name="Disponible1" type="xs:string" minOccurs="0"/>
                                <xs:element name="Disponible2" type="xs:string" minOccurs="0"/>
                             </xs:sequence>
                          </xs:complexType>
                       </xs:element>
                    </xs:choice>
                 </xs:complexType>
              </xs:element>
           </xs:schema>
           <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
              <NewDataSet xmlns="">
                 <Table diffgr:id="Table1" msdata:rowOrder="0">
                    <Registro>1</Registro>
                    <Campania>*****</Campania>
                    <Instancia>*****</Instancia>
                    <Intentos>4</Intentos>
                    <Duración_x0020_Total>236</Duración_x0020_Total>
                    <Duración_x0020_Preview>243</Duración_x0020_Preview>
                    <Duración_x0020_Llamada>0</Duración_x0020_Llamada>
                    <Estado_x0020_Registro>Registro Gestionado</Estado_x0020_Registro>
                    <Estado_x0020_de_x0020_la_x0020_Última_x0020_Gestión>No Efectivo</Estado_x0020_de_x0020_la_x0020_Última_x0020_Gestión>
                    <Último_x0020_Teléfono_x0020_Marcado>*******</Último_x0020_Teléfono_x0020_Marcado>
                    <Bonificación_x0020_de_x0020_la_x0020_Última_x0020_Gestión>0</Bonificación_x0020_de_x0020_la_x0020_Última_x0020_Gestión>
                    <Gestión_x0020_Nivel_x0020_1>CERRADO POR INTENTOS</Gestión_x0020_Nivel_x0020_1>
                    <Fecha_x0020_Gestión>16/05/2019</Fecha_x0020_Gestión>
                    <Hora_x0020_Gestión>18:42:29</Hora_x0020_Gestión>
                    <Usuario_x0020_Última_x0020_Modificación>********</Usuario_x0020_Última_x0020_Modificación>
                    <Nombres_x0020_Usuario_x0020_Última_x0020_Modificación>*******</Nombres_x0020_Usuario_x0020_Última_x0020_Modificación>
                    <Apellidos_x0020_Usuario_x0020_Última_x0020_Modificación>*****</Apellidos_x0020_Usuario_x0020_Última_x0020_Modificación>
                    <Usuario_x0020_Asignado>******</Usuario_x0020_Asignado>
                    <Nombres_x0020_Usuario_x0020_Asignado>******</Nombres_x0020_Usuario_x0020_Asignado>
                    <Apellidos_x0020_Usuario_x0020_Asignado>*****</Apellidos_x0020_Usuario_x0020_Asignado>
                    <Usuario_x0020_Última_x0020_Gestión>*****</Usuario_x0020_Última_x0020_Gestión>
                    <Nombres_x0020_Usuario_x0020_Última_x0020_Gestión>*******</Nombres_x0020_Usuario_x0020_Última_x0020_Gestión>
                    <Apellidos_x0020_Usuario_x0020_Última_x0020_Gestión>*****</Apellidos_x0020_Usuario_x0020_Última_x0020_Gestión>
                    <Fecha_x0020_Creación>16/05/2019</Fecha_x0020_Creación>
                    <Hora_x0020_Creación>09:43:29</Hora_x0020_Creación>
                    <Grupo_x0020_Finaliza_x0020_Última_x0020_Gestión>SALUDO</Grupo_x0020_Finaliza_x0020_Última_x0020_Gestión>
                    <Origen>Archivo de Carga</Origen>
                    <Versión_x0020_Encuesta>1</Versión_x0020_Encuesta>
                    <Fecha_x0020_Versión_x0020_Encuesta>17/08/2016</Fecha_x0020_Versión_x0020_Encuesta>
                    <Hora_x0020_Versión_x0020_Encuesta>14:56:05</Hora_x0020_Versión_x0020_Encuesta>
                    <Versión_x0020_Estructura_x0020_de_x0020_Carga>4</Versión_x0020_Estructura_x0020_de_x0020_Carga>
                    <Fecha_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga>08/02/2019</Fecha_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga>
                    <Hora_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga>08:48:00</Hora_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga>
                    <Estado_x0020_QA>Ninguno</Estado_x0020_QA>
                    <Tipo_x0020_de_x0020_Gestión>******</Tipo_x0020_de_x0020_Gestión>
                    <CodCliente>*****</CodCliente>
                    <Nombre_x0020_Establecimiento>**********</Nombre_x0020_Establecimiento>
                    <Responsable_x0020_Negocio>********</Responsable_x0020_Negocio>
                    <Tipo_x0020_de_x0020_Cliente_x0020__x0028_D_x002F_E_x0029_>***</Tipo_x0020_de_x0020_Cliente_x0020__x0028_D_x002F_E_x0029_>
                    <ABC>***</ABC>
                    <Gerencia>******</Gerencia>
                    <Frecuencia_x0020_de_x0020_llamada>*********</Frecuencia_x0020_de_x0020_llamada>
                    <Ciudad>*********</Ciudad>
                    <Disponible1>*******</Disponible1>
                    <Disponible2>*********</Disponible2>
                 </Table>
              </NewDataSet>
           </diffgr:diffgram>
        </Data>
        <Error_Number>0</Error_Number>
     </GenerateReportResult>
  </GenerateReportResponse>
 </soap:Body>
</soap:Envelope>';

;WITH XMLNAMESPACES('http://schemas.xmlsoap.org/soap/envelope/' AS soap,
                'http://TPColTPMarketing.teleperformance.co' AS ns,
                'urn:schemas-microsoft-com:xml-diffgram-v1' AS dg)
SELECT
 XC.value('Registro[1]','BIGINT') as Registro
,XC.value('Campania[1]','varchar(500)') as Campania
,XC.value('Instancia[1]','varchar(500)') as Instancia
,XC.value('Intentos[1]','INT') as Intentos
,XC.value('Duración_x0020_Total[1]','int') as DuracionTotal
,XC.value('Duración_x0020_Preview[1]','int') as DuracionPreview
,XC.value('Duración_x0020_Llamada[1]','int') as DuracionLlamada
,XC.value('Estado_x0020_Registro[1]', 'varchar(500)') as EstadoRegistro
,XC.value('Estado_x0020_de_x0020_la_x0020_Última_x0020_Gestión[1]', 'varchar(500)') as Estado_UltimaGestion
,XC.value('Último_x0020_Teléfono_x0020_Marcado[1]','varchar(500)') as UltimoTelefonoMarcado
,XC.value('Bonificación_x0020_de_x0020_la_x0020_Última_x0020_Gestión[1]', 'int') as Bonificacion_UltimaGestion
,XC.value('Fecha_x0020_Hora_x0020_Agenda[1]', 'datetime') as BonificacionHoraAgenda
,XC.value('Teléfono_x0020_Agenda[1]', 'varchar(500)') as TelefonoAgenda
,XC.value('Gestión_x0020_Nivel_x0020_1[1]', 'varchar(500)') as GestionNivel_1
,XC.value('Gestión_x0020_Nivel_x0020_2[1]', 'varchar(500)') as GestionNivel_2
,XC.value('Gestión_x0020_Nivel_x0020_3[1]', 'varchar(500)') as GestionNivel_3
,XC.value('Gestión_x0020_Nivel_x0020_4[1]', 'varchar(500)') as GestionNivel_4
,XC.value('Gestión_x0020_Nivel_x0020_5[1]', 'varchar(500)') as GestionNivel_5
,XC.value('Fecha_x0020_Gestión[1]', 'varchar(500)') as FechaGestion
,XC.value('Hora_x0020_Gestión[1]', 'varchar(500)') as HoraGestion
,XC.value('Resultado[1]', 'varchar(500)') as Resultado
,XC.value('Observaciones[1]', 'varchar(500)') as Observaciones
,XC.value('Usuario_x0020_Última_x0020_Modificación[1]', 'varchar(500)') as Usuario_UltimaModificacion
,XC.value('Nombres_x0020_Usuario_x0020_Última_x0020_Modificación[1]', 'varchar(500)') as NombresUsuario_UltimaModificacion
,XC.value('Apellidos_x0020_Usuario_x0020_Última_x0020_Modificación[1]', 'varchar(500)') as ApellidosUsuario_UltimaModificacion
,XC.value('Usuario_x0020_Asignado[1]','varchar(500)') as UsuarioAsignado
,XC.value('Nombres_x0020_Usuario_x0020_Asignado[1]', 'varchar(500)') as Nombres_UsuarioAsignado
,XC.value('Apellidos_x0020_Usuario_x0020_Asignado[1]','varchar(500)') as Apellidos_UsuarioAsignado
,XC.value('Usuario_x0020_Última_x0020_Gestión[1]', 'varchar(500)') as Usuario_UltimaGestion
,XC.value('Nombres_x0020_Usuario_x0020_Última_x0020_Gestión[1]', 'varchar(500)') as NombresUsuario_UltimaGestion
,XC.value('Apellidos_x0020_Usuario_x0020_Última_x0020_Gestión[1]', 'varchar(500)') as ApellidosUsuario_UltimaGestion
,XC.value('EtiquetaCallCopyUser3[1]','varchar(500)') as EtiquetaCallCopyUser_3
,XC.value('EtiquetaCallCopyUser4[1]', 'varchar(500)') as EtiquetaCallCopyUser_4
,XC.value('EtiquetaCallCopyUser10[1]', 'varchar(500)') as EtiquetaCallCopyUser_10
,XC.value('EtiquetaCallCopyUser11[1]', 'varchar(500)') as EtiquetaCallaCopyUser_11
,XC.value('EtiquetaCallCopyUser12[1]', 'varchar(500)') as EtiquetaCallCopyUser_12
,XC.value('EtiquetaCallCopyUser13[1]', 'varchar(500)') as EtiquetaCallCopyUser_13
,XC.value('Fecha_x0020_Creación[1]', 'varchar(500)') as FechaCreación
,XC.value('Hora_x0020_Creación[1]', 'varchar(500)') as HoraCreacion
,XC.value('Grupo_x0020_Inicia_x0020_Última_x0020_Gestión[1]','varchar(500)') as GrupoInicia_UltimaGestion
,XC.value('Grupo_x0020_Finaliza_x0020_Última_x0020_Gestión[1]', 'varchar(500)') as GrupoFinaliza_UltimaGestion
,XC.value('Origen[1]', 'varchar(500)') as Origen
,XC.value('Versión_x0020_Encuesta[1]', 'varchar(500)') as VersionEncuesta
,XC.value('Fecha_x0020_Versión_x0020_Encuesta[1]', 'varchar(500)') as Fecha_VersionEncuesta
,XC.value('Hora_x0020_Versión_x0020_Encuesta[1]', 'varchar(500)') as Hora_VersionEncuesta
,XC.value('Versión_x0020_Estructura_x0020_de_x0020_Carga[1]', 'varchar(500)') as Version_EstructuraCarga
,XC.value('Fecha_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga[1]', 'varchar(500)') as FechaVersion_EstructuraCarga
,XC.value('Hora_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga[1]', 'varchar(500)') as HoraVersion_EstructuraCarga
,XC.value('Estado_x0020_QA[1]','varchar(500)') as Estado_QA
,XC.value('Grupo_x0020_Negocio[1]','varchar(500)') as GrupoNegocio
,XC.value('Grupo_x0020_Llamada[1]', 'varchar(500)') as GrupoLlamada
,XC.value('Tipo_x0020_de_x0020_Gestión[1]', 'varchar(500)') as TipoGestion
,XC.value('CodCliente[1]','VARCHAR(500)') as CodCliente
,XC.value('Nombre_x0020_Establecimiento[1]','varchar(500)') as NombreEstablecimiento
,XC.value('Responsable_x0020_Negocio[50]', 'varchar(500)') as ResponsableNegocio
,XC.value('Tipo_x0020_de_x0020_Cliente_x0020__x0028_D_x002F_E_x0029_[1]', 'varchar(500)') as TipoCliente
,XC.value('ABC[1]', 'varchar(500)') as ABC
,XC.value('Sector[1]', 'varchar(500)') as Sector
,XC.value('Gerencia[1]','varchar(500)') as Gerencia
,XC.value('Frecuencia_x0020_de_x0020_llamada[1]', 'varchar(500)') as FrecuenciaLlamada
,XC.value('Telefono_x0020_Movil_x0020_1[1]', 'varchar(500)') as TelefonoMovil_1
,XC.value('Telefono_x0020_Movil_x0020_2[1]', 'varchar(500)') as TelefonoMovil_2
,XC.value('Telefono_x0020_Fijo_x0020_1[1]', 'varchar(500)') as TelefonoFijo_1
,XC.value('Telefono_x0020_Fijo_x0020_2[1]', 'varchar(500)') as TelefonoFijo_2
,XC.value('Telefono_x0020_Adicional_x0020__x0028_M_x0020_o_x0020_F_x0029_[1]', 'varchar(500)') as TelefonoAdicional
,XC.value('Ciudad[1]', 'varchar(500)') as Ciudad
,XC.value('Disponible1[1]', 'varchar(500)') as Disponible1
,XC.value('Disponible2[1]', 'varchar(500)') as Disponible2
FROM
@xml.nodes('/soap:Envelope/soap:Body/ns:GenerateReportResponse/ns:GenerateReportResult/Data/dg:diffgram/NewDataSet/Table') AS XT(XC)
</code>```

But when executing it, it generates the following error 'The data type 'VARCHAR(500)1' used in the VALUE method is invalid' Why is this happening? Help with this error. Thanks

Pdta: I'm sorry because the name of the fields is in Spanish but it's for a client who speaks Spanish

UPDATED

The error was on this line

```<code>XC.value ('CodCliente[1]', 'VARCHAR(500)[1]')
</code>```

I already corrected it but the rows are empty, I changed VARCHAR for NVARCHAR(MAX)

Image here

答:
Your XML is a bit weird. There are many namespaces involved... Namely the repeating declaration of a default namespaces (xmlns="blah" or xmlns="") should be avoided.

However, I'd suggest this query:

```<code>;WITH XMLNAMESPACES('http://schemas.xmlsoap.org/soap/envelope/' AS soap,
                    'http://tempuri.org' AS outerDflt,
                    'urn:schemas-microsoft-com:xml-diffgram-v1' AS diffgr)
SELECT REPLACE(tblColumns.value('local-name(.)','nvarchar(500)'),'_x0020_',' ') AS ElementKey
      ,tblColumns.value('text()[1]','nvarchar(500)') AS ElementValue
FROM @xml.nodes('/soap:Envelope
                 /soap:Body
                 /outerDflt:GenerateReportResponse
                 /outerDflt:GenerateReportResult
                 /outerDflt:Data
                 /diffgr:diffgram
                 /NewDataSet
                 /Table
                 /*') A(tblColumns);
</code>```

The easy-cheesy approach, which would actually return the same, was this:

```<code>SELECT REPLACE(tblColumns.value('local-name(.)','nvarchar(500)'),'_x0020_',' ') AS ElementKey
      ,tblColumns.value('text()[1]','nvarchar(500)') AS ElementValue
FROM @xml.nodes('//Table/*') A(tblColumns);
</code>```

The second works, because right before
 the default namespace is re-set to an empty namespace. If there is no other element
 within your structure the deep search to //Table/* will find all nodes below this element.

Both queries return this (you might use _ instead of a blank to replace the _x0020_)

```<code>+-----------------------------------------+----------------------+
| ElementKey                              | ElementValue         |
+-----------------------------------------+----------------------+
| Registro                                | 1                    |
+-----------------------------------------+----------------------+
| Campania                                | *****                |
+-----------------------------------------+----------------------+
| Instancia                               | *****                |
+-----------------------------------------+----------------------+
| Intentos                                | 4                    |
+-----------------------------------------+----------------------+
| Duración Total                          | 236                  |
+-----------------------------------------+----------------------+
| Duración Preview                        | 243                  |
+-----------------------------------------+----------------------+
| Duración Llamada                        | 0                    |
+-----------------------------------------+----------------------+
| Estado Registro                         | Registro Gestionado  |
+-----------------------------------------+----------------------+
| Estado de la Última Gestión             | No Efectivo          |
+-----------------------------------------+----------------------+
| Último Teléfono Marcado                 | *******              |
+-----------------------------------------+----------------------+
| Bonificación de la Última Gestión       | 0                    |
+-----------------------------------------+----------------------+
| Gestión Nivel 1                         | CERRADO POR INTENTOS |
+-----------------------------------------+----------------------+
| Fecha Gestión                           | 16/05/2019           |
+-----------------------------------------+----------------------+
| Hora Gestión                            | 18:42:29             |
+-----------------------------------------+----------------------+
| Usuario Última Modificación             | ********             |
+-----------------------------------------+----------------------+
| Nombres Usuario Última Modificación     | *******              |
+-----------------------------------------+----------------------+
| Apellidos Usuario Última Modificación   | *****                |
+-----------------------------------------+----------------------+
| Usuario Asignado                        | ******               |
+-----------------------------------------+----------------------+
| Nombres Usuario Asignado                | ******               |
+-----------------------------------------+----------------------+
| Apellidos Usuario Asignado              | *****                |
+-----------------------------------------+----------------------+
| Usuario Última Gestión                  | *****                |
+-----------------------------------------+----------------------+
| Nombres Usuario Última Gestión          | *******              |
+-----------------------------------------+----------------------+
| Apellidos Usuario Última Gestión        | *****                |
+-----------------------------------------+----------------------+
| Fecha Creación                          | 16/05/2019           |
+-----------------------------------------+----------------------+
| Hora Creación                           | 09:43:29             |
+-----------------------------------------+----------------------+
| Grupo Finaliza Última Gestión           | SALUDO               |
+-----------------------------------------+----------------------+
| Origen                                  | Archivo de Carga     |
+-----------------------------------------+----------------------+
| Versión Encuesta                        | 1                    |
+-----------------------------------------+----------------------+
| Fecha Versión Encuesta                  | 17/08/2016           |
+-----------------------------------------+----------------------+
| Hora Versión Encuesta                   | 14:56:05             |
+-----------------------------------------+----------------------+
| Versión Estructura de Carga             | 4                    |
+-----------------------------------------+----------------------+
| Fecha Versión Estructura de Carga       | 08/02/2019           |
+-----------------------------------------+----------------------+
| Hora Versión Estructura de Carga        | 08:48:00             |
+-----------------------------------------+----------------------+
| Estado QA                               | Ninguno              |
+-----------------------------------------+----------------------+
| Tipo de Gestión                         | ******               |
+-----------------------------------------+----------------------+
| CodCliente                              | *****                |
+-----------------------------------------+----------------------+
| Nombre Establecimiento                  | **********           |
+-----------------------------------------+----------------------+
| Responsable Negocio                     | ********             |
+-----------------------------------------+----------------------+
| Tipo de Cliente _x0028_D_x002F_E_x0029_ | ***                  |
+-----------------------------------------+----------------------+
| ABC                                     | ***                  |
+-----------------------------------------+----------------------+
| Gerencia                                | ******               |
+-----------------------------------------+----------------------+
| Frecuencia de llamada                   | *********            |
+-----------------------------------------+----------------------+
| Ciudad                                  | *********            |
+-----------------------------------------+----------------------+
| Disponible1                             | *******              |
+-----------------------------------------+----------------------+
| Disponible2                             | *********            |
+-----------------------------------------+----------------------+
</code>```

Body:
I have an XML and I want it to look like a table in sql, this is the structure

declare @xml xml =
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
  <GenerateReportResponse
    xmlns="http://tempuri.org">
     <GenerateReportResult>
        <Data>
           <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
              <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Table" msdata:UseCurrentLocale="true">
                 <xs:complexType>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                       <xs:element name="Table">
                          <xs:complexType>
                             <xs:sequence>
                                <xs:element name="Registro" type="xs:long" minOccurs="0"/>
                                <xs:element name="Campania" type="xs:string" minOccurs="0"/>
                                <xs:element name="Instancia" type="xs:string" minOccurs="0"/>
                                <xs:element name="Intentos" type="xs:int" minOccurs="0"/>
                                <xs:element name="Duración_x0020_Total" type="xs:int" minOccurs="0"/>
                                <xs:element name="Duración_x0020_Preview" type="xs:int" minOccurs="0"/>
                                <xs:element name="Duración_x0020_Llamada" type="xs:int" minOccurs="0"/>
                                <xs:element name="Estado_x0020_Registro" type="xs:string" minOccurs="0"/>
                                <xs:element name="Estado_x0020_de_x0020_la_x0020_Última_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Último_x0020_Teléfono_x0020_Marcado" type="xs:string" minOccurs="0"/>
                                <xs:element name="Bonificación_x0020_de_x0020_la_x0020_Última_x0020_Gestión" type="xs:int" minOccurs="0"/>
                                <xs:element name="Fecha_x0020_Hora_x0020_Agenda" type="xs:dateTime" minOccurs="0"/>
                                <xs:element name="Teléfono_x0020_Agenda" type="xs:string" minOccurs="0"/>
                                <xs:element name="Gestión_x0020_Nivel_x0020_1" type="xs:string" minOccurs="0"/>
                                <xs:element name="Gestión_x0020_Nivel_x0020_2" type="xs:string" minOccurs="0"/>
                                <xs:element name="Gestión_x0020_Nivel_x0020_3" type="xs:string" minOccurs="0"/>
                                <xs:element name="Gestión_x0020_Nivel_x0020_4" type="xs:string" minOccurs="0"/>
                                <xs:element name="Gestión_x0020_Nivel_x0020_5" type="xs:string" minOccurs="0"/>
                                <xs:element name="Fecha_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Hora_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Resultado" type="xs:string" minOccurs="0"/>
                                <xs:element name="Observaciones" type="xs:string" minOccurs="0"/>
                                <xs:element name="Usuario_x0020_Última_x0020_Modificación" type="xs:string" minOccurs="0"/>
                                <xs:element name="Nombres_x0020_Usuario_x0020_Última_x0020_Modificación" type="xs:string" minOccurs="0"/>
                                <xs:element name="Apellidos_x0020_Usuario_x0020_Última_x0020_Modificación" type="xs:string" minOccurs="0"/>
                                <xs:element name="Usuario_x0020_Asignado" type="xs:string" minOccurs="0"/>
                                <xs:element name="Nombres_x0020_Usuario_x0020_Asignado" type="xs:string" minOccurs="0"/>
                                <xs:element name="Apellidos_x0020_Usuario_x0020_Asignado" type="xs:string" minOccurs="0"/>
                                <xs:element name="Usuario_x0020_Última_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Nombres_x0020_Usuario_x0020_Última_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Apellidos_x0020_Usuario_x0020_Última_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="EtiquetaCallCopyUser3" type="xs:string" minOccurs="0"/>
                                <xs:element name="EtiquetaCallCopyUser4" type="xs:string" minOccurs="0"/>
                                <xs:element name="EtiquetaCallCopyUser10" type="xs:string" minOccurs="0"/>
                                <xs:element name="EtiquetaCallCopyUser11" type="xs:string" minOccurs="0"/>
                                <xs:element name="EtiquetaCallCopyUser12" type="xs:string" minOccurs="0"/>
                                <xs:element name="EtiquetaCallCopyUser13" type="xs:string" minOccurs="0"/>
                                <xs:element name="Fecha_x0020_Creación" type="xs:string" minOccurs="0"/>
                                <xs:element name="Hora_x0020_Creación" type="xs:string" minOccurs="0"/>
                                <xs:element name="Grupo_x0020_Inicia_x0020_Última_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Grupo_x0020_Finaliza_x0020_Última_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="Origen" type="xs:string" minOccurs="0"/>
                                <xs:element name="Versión_x0020_Encuesta" type="xs:string" minOccurs="0"/>
                                <xs:element name="Fecha_x0020_Versión_x0020_Encuesta" type="xs:string" minOccurs="0"/>
                                <xs:element name="Hora_x0020_Versión_x0020_Encuesta" type="xs:string" minOccurs="0"/>
                                <xs:element name="Versión_x0020_Estructura_x0020_de_x0020_Carga" type="xs:string" minOccurs="0"/>
                                <xs:element name="Fecha_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga" type="xs:string" minOccurs="0"/>
                                <xs:element name="Hora_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga" type="xs:string" minOccurs="0"/>
                                <xs:element name="Estado_x0020_QA" type="xs:string" minOccurs="0"/>
                                <xs:element name="Grupo_x0020_Negocio" type="xs:string" minOccurs="0"/>
                                <xs:element name="Grupo_x0020_Llamada" type="xs:string" minOccurs="0"/>
                                <xs:element name="Tipo_x0020_de_x0020_Gestión" type="xs:string" minOccurs="0"/>
                                <xs:element name="CodCliente" type="xs:string" minOccurs="0"/>
                                <xs:element name="Nombre_x0020_Establecimiento" type="xs:string" minOccurs="0"/>
                                <xs:element name="Responsable_x0020_Negocio" type="xs:string" minOccurs="0"/>
                                <xs:element name="Tipo_x0020_de_x0020_Cliente_x0020__x0028_D_x002F_E_x0029_" type="xs:string" minOccurs="0"/>
                                <xs:element name="ABC" type="xs:string" minOccurs="0"/>
                                <xs:element name="Sector" type="xs:string" minOccurs="0"/>
                                <xs:element name="Gerencia" type="xs:string" minOccurs="0"/>
                                <xs:element name="Frecuencia_x0020_de_x0020_llamada" type="xs:string" minOccurs="0"/>
                                <xs:element name="Telefono_x0020_Movil_x0020_1" type="xs:string" minOccurs="0"/>
                                <xs:element name="Telefono_x0020_Movil_x0020_2" type="xs:string" minOccurs="0"/>
                                <xs:element name="Telefono_x0020_Fijo_x0020_1" type="xs:string" minOccurs="0"/>
                                <xs:element name="Telefono_x0020_Fijo_x0020_2" type="xs:string" minOccurs="0"/>
                                <xs:element name="Telefono_x0020_Adicional_x0020__x0028_M_x0020_o_x0020_F_x0029_" type="xs:string" minOccurs="0"/>
                                <xs:element name="Ciudad" type="xs:string" minOccurs="0"/>
                                <xs:element name="Disponible1" type="xs:string" minOccurs="0"/>
                                <xs:element name="Disponible2" type="xs:string" minOccurs="0"/>
                             </xs:sequence>
                          </xs:complexType>
                       </xs:element>
                    </xs:choice>
                 </xs:complexType>
              </xs:element>
           </xs:schema>
           <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
              <NewDataSet xmlns="">

                    <Registro>1</Registro>
                    <Campania>*****</Campania>
                    <Instancia>*****</Instancia>
                    <Intentos>4</Intentos>
                    <Duración_x0020_Total>236</Duración_x0020_Total>
                    <Duración_x0020_Preview>243</Duración_x0020_Preview>
                    <Duración_x0020_Llamada>0</Duración_x0020_Llamada>
                    <Estado_x0020_Registro>Registro Gestionado</Estado_x0020_Registro>
                    <Estado_x0020_de_x0020_la_x0020_Última_x0020_Gestión>No Efectivo</Estado_x0020_de_x0020_la_x0020_Última_x0020_Gestión>
                    <Último_x0020_Teléfono_x0020_Marcado>*******</Último_x0020_Teléfono_x0020_Marcado>
                    <Bonificación_x0020_de_x0020_la_x0020_Última_x0020_Gestión>0</Bonificación_x0020_de_x0020_la_x0020_Última_x0020_Gestión>
                    <Gestión_x0020_Nivel_x0020_1>CERRADO POR INTENTOS</Gestión_x0020_Nivel_x0020_1>
                    <Fecha_x0020_Gestión>16/05/2019</Fecha_x0020_Gestión>
                    <Hora_x0020_Gestión>18:42:29</Hora_x0020_Gestión>
                    <Usuario_x0020_Última_x0020_Modificación>********</Usuario_x0020_Última_x0020_Modificación>
                    <Nombres_x0020_Usuario_x0020_Última_x0020_Modificación>*******</Nombres_x0020_Usuario_x0020_Última_x0020_Modificación>
                    <Apellidos_x0020_Usuario_x0020_Última_x0020_Modificación>*****</Apellidos_x0020_Usuario_x0020_Última_x0020_Modificación>
                    <Usuario_x0020_Asignado>******</Usuario_x0020_Asignado>
                    <Nombres_x0020_Usuario_x0020_Asignado>******</Nombres_x0020_Usuario_x0020_Asignado>
                    <Apellidos_x0020_Usuario_x0020_Asignado>*****</Apellidos_x0020_Usuario_x0020_Asignado>
                    <Usuario_x0020_Última_x0020_Gestión>*****</Usuario_x0020_Última_x0020_Gestión>
                    <Nombres_x0020_Usuario_x0020_Última_x0020_Gestión>*******</Nombres_x0020_Usuario_x0020_Última_x0020_Gestión>
                    <Apellidos_x0020_Usuario_x0020_Última_x0020_Gestión>*****</Apellidos_x0020_Usuario_x0020_Última_x0020_Gestión>
                    <Fecha_x0020_Creación>16/05/2019</Fecha_x0020_Creación>
                    <Hora_x0020_Creación>09:43:29</Hora_x0020_Creación>
                    <Grupo_x0020_Finaliza_x0020_Última_x0020_Gestión>SALUDO</Grupo_x0020_Finaliza_x0020_Última_x0020_Gestión>
                    <Origen>Archivo de Carga</Origen>
                    <Versión_x0020_Encuesta>1</Versión_x0020_Encuesta>
                    <Fecha_x0020_Versión_x0020_Encuesta>17/08/2016</Fecha_x0020_Versión_x0020_Encuesta>
                    <Hora_x0020_Versión_x0020_Encuesta>14:56:05</Hora_x0020_Versión_x0020_Encuesta>
                    <Versión_x0020_Estructura_x0020_de_x0020_Carga>4</Versión_x0020_Estructura_x0020_de_x0020_Carga>
                    <Fecha_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga>08/02/2019</Fecha_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga>
                    <Hora_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga>08:48:00</Hora_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga>
                    <Estado_x0020_QA>Ninguno</Estado_x0020_QA>
                    <Tipo_x0020_de_x0020_Gestión>******</Tipo_x0020_de_x0020_Gestión>
                    <CodCliente>*****</CodCliente>
                    <Nombre_x0020_Establecimiento>**********</Nombre_x0020_Establecimiento>
                    <Responsable_x0020_Negocio>********</Responsable_x0020_Negocio>
                    <Tipo_x0020_de_x0020_Cliente_x0020__x0028_D_x002F_E_x0029_>***</Tipo_x0020_de_x0020_Cliente_x0020__x0028_D_x002F_E_x0029_>
                    <ABC>***</ABC>
                    <Gerencia>******</Gerencia>
                    <Frecuencia_x0020_de_x0020_llamada>*********</Frecuencia_x0020_de_x0020_llamada>
                    <Ciudad>*********</Ciudad>
                    <Disponible1>*******</Disponible1>
                    <Disponible2>*********</Disponible2>

              </NewDataSet>
           </diffgr:diffgram>
        </Data>
        <Error_Number>0</Error_Number>
     </GenerateReportResult>
  </GenerateReportResponse>
 </soap:Body>
</soap:Envelope>';

;WITH XMLNAMESPACES('http://schemas.xmlsoap.org/soap/envelope/' AS soap,
                'http://TPColTPMarketing.teleperformance.co' AS ns,
                'urn:schemas-microsoft-com:xml-diffgram-v1' AS dg)
SELECT
 XC.value('Registro[1]','BIGINT') as Registro
,XC.value('Campania[1]','varchar(500)') as Campania
,XC.value('Instancia[1]','varchar(500)') as Instancia
,XC.value('Intentos[1]','INT') as Intentos
,XC.value('Duración_x0020_Total[1]','int') as DuracionTotal
,XC.value('Duración_x0020_Preview[1]','int') as DuracionPreview
,XC.value('Duración_x0020_Llamada[1]','int') as DuracionLlamada
,XC.value('Estado_x0020_Registro[1]', 'varchar(500)') as EstadoRegistro
,XC.value('Estado_x0020_de_x0020_la_x0020_Última_x0020_Gestión[1]', 'varchar(500)') as Estado_UltimaGestion
,XC.value('Último_x0020_Teléfono_x0020_Marcado[1]','varchar(500)') as UltimoTelefonoMarcado
,XC.value('Bonificación_x0020_de_x0020_la_x0020_Última_x0020_Gestión[1]', 'int') as Bonificacion_UltimaGestion
,XC.value('Fecha_x0020_Hora_x0020_Agenda[1]', 'datetime') as BonificacionHoraAgenda
,XC.value('Teléfono_x0020_Agenda[1]', 'varchar(500)') as TelefonoAgenda
,XC.value('Gestión_x0020_Nivel_x0020_1[1]', 'varchar(500)') as GestionNivel_1
,XC.value('Gestión_x0020_Nivel_x0020_2[1]', 'varchar(500)') as GestionNivel_2
,XC.value('Gestión_x0020_Nivel_x0020_3[1]', 'varchar(500)') as GestionNivel_3
,XC.value('Gestión_x0020_Nivel_x0020_4[1]', 'varchar(500)') as GestionNivel_4
,XC.value('Gestión_x0020_Nivel_x0020_5[1]', 'varchar(500)') as GestionNivel_5
,XC.value('Fecha_x0020_Gestión[1]', 'varchar(500)') as FechaGestion
,XC.value('Hora_x0020_Gestión[1]', 'varchar(500)') as HoraGestion
,XC.value('Resultado[1]', 'varchar(500)') as Resultado
,XC.value('Observaciones[1]', 'varchar(500)') as Observaciones
,XC.value('Usuario_x0020_Última_x0020_Modificación[1]', 'varchar(500)') as Usuario_UltimaModificacion
,XC.value('Nombres_x0020_Usuario_x0020_Última_x0020_Modificación[1]', 'varchar(500)') as NombresUsuario_UltimaModificacion
,XC.value('Apellidos_x0020_Usuario_x0020_Última_x0020_Modificación[1]', 'varchar(500)') as ApellidosUsuario_UltimaModificacion
,XC.value('Usuario_x0020_Asignado[1]','varchar(500)') as UsuarioAsignado
,XC.value('Nombres_x0020_Usuario_x0020_Asignado[1]', 'varchar(500)') as Nombres_UsuarioAsignado
,XC.value('Apellidos_x0020_Usuario_x0020_Asignado[1]','varchar(500)') as Apellidos_UsuarioAsignado
,XC.value('Usuario_x0020_Última_x0020_Gestión[1]', 'varchar(500)') as Usuario_UltimaGestion
,XC.value('Nombres_x0020_Usuario_x0020_Última_x0020_Gestión[1]', 'varchar(500)') as NombresUsuario_UltimaGestion
,XC.value('Apellidos_x0020_Usuario_x0020_Última_x0020_Gestión[1]', 'varchar(500)') as ApellidosUsuario_UltimaGestion
,XC.value('EtiquetaCallCopyUser3[1]','varchar(500)') as EtiquetaCallCopyUser_3
,XC.value('EtiquetaCallCopyUser4[1]', 'varchar(500)') as EtiquetaCallCopyUser_4
,XC.value('EtiquetaCallCopyUser10[1]', 'varchar(500)') as EtiquetaCallCopyUser_10
,XC.value('EtiquetaCallCopyUser11[1]', 'varchar(500)') as EtiquetaCallaCopyUser_11
,XC.value('EtiquetaCallCopyUser12[1]', 'varchar(500)') as EtiquetaCallCopyUser_12
,XC.value('EtiquetaCallCopyUser13[1]', 'varchar(500)') as EtiquetaCallCopyUser_13
,XC.value('Fecha_x0020_Creación[1]', 'varchar(500)') as FechaCreación
,XC.value('Hora_x0020_Creación[1]', 'varchar(500)') as HoraCreacion
,XC.value('Grupo_x0020_Inicia_x0020_Última_x0020_Gestión[1]','varchar(500)') as GrupoInicia_UltimaGestion
,XC.value('Grupo_x0020_Finaliza_x0020_Última_x0020_Gestión[1]', 'varchar(500)') as GrupoFinaliza_UltimaGestion
,XC.value('Origen[1]', 'varchar(500)') as Origen
,XC.value('Versión_x0020_Encuesta[1]', 'varchar(500)') as VersionEncuesta
,XC.value('Fecha_x0020_Versión_x0020_Encuesta[1]', 'varchar(500)') as Fecha_VersionEncuesta
,XC.value('Hora_x0020_Versión_x0020_Encuesta[1]', 'varchar(500)') as Hora_VersionEncuesta
,XC.value('Versión_x0020_Estructura_x0020_de_x0020_Carga[1]', 'varchar(500)') as Version_EstructuraCarga
,XC.value('Fecha_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga[1]', 'varchar(500)') as FechaVersion_EstructuraCarga
,XC.value('Hora_x0020_Versión_x0020_Estructura_x0020_de_x0020_Carga[1]', 'varchar(500)') as HoraVersion_EstructuraCarga
,XC.value('Estado_x0020_QA[1]','varchar(500)') as Estado_QA
,XC.value('Grupo_x0020_Negocio[1]','varchar(500)') as GrupoNegocio
,XC.value('Grupo_x0020_Llamada[1]', 'varchar(500)') as GrupoLlamada
,XC.value('Tipo_x0020_de_x0020_Gestión[1]', 'varchar(500)') as TipoGestion
,XC.value('CodCliente[1]','VARCHAR(500)') as CodCliente
,XC.value('Nombre_x0020_Establecimiento[1]','varchar(500)') as NombreEstablecimiento
,XC.value('Responsable_x0020_Negocio[50]', 'varchar(500)') as ResponsableNegocio
,XC.value('Tipo_x0020_de_x0020_Cliente_x0020__x0028_D_x002F_E_x0029_[1]', 'varchar(500)') as TipoCliente
,XC.value('ABC[1]', 'varchar(500)') as ABC
,XC.value('Sector[1]', 'varchar(500)') as Sector
,XC.value('Gerencia[1]','varchar(500)') as Gerencia
,XC.value('Frecuencia_x0020_de_x0020_llamada[1]', 'varchar(500)') as FrecuenciaLlamada
,XC.value('Telefono_x0020_Movil_x0020_1[1]', 'varchar(500)') as TelefonoMovil_1
,XC.value('Telefono_x0020_Movil_x0020_2[1]', 'varchar(500)') as TelefonoMovil_2
,XC.value('Telefono_x0020_Fijo_x0020_1[1]', 'varchar(500)') as TelefonoFijo_1
,XC.value('Telefono_x0020_Fijo_x0020_2[1]', 'varchar(500)') as TelefonoFijo_2
,XC.value('Telefono_x0020_Adicional_x0020__x0028_M_x0020_o_x0020_F_x0029_[1]', 'varchar(500)') as TelefonoAdicional
,XC.value('Ciudad[1]', 'varchar(500)') as Ciudad
,XC.value('Disponible1[1]', 'varchar(500)') as Disponible1
,XC.value('Disponible2[1]', 'varchar(500)') as Disponible2
FROM
@xml.nodes('/soap:Envelope/soap:Body/ns:GenerateReportResponse/ns:GenerateReportResult/Data/dg:diffgram/NewDataSet/Table') AS XT(XC)

But when executing it, it generates the following error 'The data type 'VARCHAR(500)1' used in the VALUE method is invalid' Why is this happening? Help with this error. Thanks

Pdta: I'm sorry because the name of the fields is in Spanish but it's for a client who speaks Spanish

UPDATED

The error was on this line

XC.value ('CodCliente[1]', 'VARCHAR(500)[1]')

I already corrected it but the rows are empty, I changed VARCHAR for NVARCHAR(MAX)

Image here

Body:
Your XML is a bit weird. There are many namespaces involved... Namely the repeating declaration of a default namespaces (xmlns="blah" or xmlns="") should be avoided.

However, I'd suggest this query:

;WITH XMLNAMESPACES('http://schemas.xmlsoap.org/soap/envelope/' AS soap,
                    'http://tempuri.org' AS outerDflt,
                    'urn:schemas-microsoft-com:xml-diffgram-v1' AS diffgr)
SELECT REPLACE(tblColumns.value('local-name(.)','nvarchar(500)'),'_x0020_',' ') AS ElementKey
      ,tblColumns.value('text()[1]','nvarchar(500)') AS ElementValue
FROM @xml.nodes('/soap:Envelope
                 /soap:Body
                 /outerDflt:GenerateReportResponse
                 /outerDflt:GenerateReportResult
                 /outerDflt:Data
                 /diffgr:diffgram
                 /NewDataSet
                 /Table
                 /*') A(tblColumns);

The easy-cheesy approach, which would actually return the same, was this:

SELECT REPLACE(tblColumns.value('local-name(.)','nvarchar(500)'),'_x0020_',' ') AS ElementKey
      ,tblColumns.value('text()[1]','nvarchar(500)') AS ElementValue
FROM @xml.nodes('//Table/*') A(tblColumns);

The second works, because right before <Table> the default namespace is re-set to an empty namespace. If there is no other element <Table> within your structure the deep search to //Table/* will find all nodes below this element.

Both queries return this (you might use _ instead of a blank to replace the _x0020_)

+-----------------------------------------+----------------------+
| ElementKey                              | ElementValue         |
+-----------------------------------------+----------------------+
| Registro                                | 1                    |
+-----------------------------------------+----------------------+
| Campania                                | *****                |
+-----------------------------------------+----------------------+
| Instancia                               | *****                |
+-----------------------------------------+----------------------+
| Intentos                                | 4                    |
+-----------------------------------------+----------------------+
| Duración Total                          | 236                  |
+-----------------------------------------+----------------------+
| Duración Preview                        | 243                  |
+-----------------------------------------+----------------------+
| Duración Llamada                        | 0                    |
+-----------------------------------------+----------------------+
| Estado Registro                         | Registro Gestionado  |
+-----------------------------------------+----------------------+
| Estado de la Última Gestión             | No Efectivo          |
+-----------------------------------------+----------------------+
| Último Teléfono Marcado                 | *******              |
+-----------------------------------------+----------------------+
| Bonificación de la Última Gestión       | 0                    |
+-----------------------------------------+----------------------+
| Gestión Nivel 1                         | CERRADO POR INTENTOS |
+-----------------------------------------+----------------------+
| Fecha Gestión                           | 16/05/2019           |
+-----------------------------------------+----------------------+
| Hora Gestión                            | 18:42:29             |
+-----------------------------------------+----------------------+
| Usuario Última Modificación             | ********             |
+-----------------------------------------+----------------------+
| Nombres Usuario Última Modificación     | *******              |
+-----------------------------------------+----------------------+
| Apellidos Usuario Última Modificación   | *****                |
+-----------------------------------------+----------------------+
| Usuario Asignado                        | ******               |
+-----------------------------------------+----------------------+
| Nombres Usuario Asignado                | ******               |
+-----------------------------------------+----------------------+
| Apellidos Usuario Asignado              | *****                |
+-----------------------------------------+----------------------+
| Usuario Última Gestión                  | *****                |
+-----------------------------------------+----------------------+
| Nombres Usuario Última Gestión          | *******              |
+-----------------------------------------+----------------------+
| Apellidos Usuario Última Gestión        | *****                |
+-----------------------------------------+----------------------+
| Fecha Creación                          | 16/05/2019           |
+-----------------------------------------+----------------------+
| Hora Creación                           | 09:43:29             |
+-----------------------------------------+----------------------+
| Grupo Finaliza Última Gestión           | SALUDO               |
+-----------------------------------------+----------------------+
| Origen                                  | Archivo de Carga     |
+-----------------------------------------+----------------------+
| Versión Encuesta                        | 1                    |
+-----------------------------------------+----------------------+
| Fecha Versión Encuesta                  | 17/08/2016           |
+-----------------------------------------+----------------------+
| Hora Versión Encuesta                   | 14:56:05             |
+-----------------------------------------+----------------------+
| Versión Estructura de Carga             | 4                    |
+-----------------------------------------+----------------------+
| Fecha Versión Estructura de Carga       | 08/02/2019           |
+-----------------------------------------+----------------------+
| Hora Versión Estructura de Carga        | 08:48:00             |
+-----------------------------------------+----------------------+
| Estado QA                               | Ninguno              |
+-----------------------------------------+----------------------+
| Tipo de Gestión                         | ******               |
+-----------------------------------------+----------------------+
| CodCliente                              | *****                |
+-----------------------------------------+----------------------+
| Nombre Establecimiento                  | **********           |
+-----------------------------------------+----------------------+
| Responsable Negocio                     | ********             |
+-----------------------------------------+----------------------+
| Tipo de Cliente _x0028_D_x002F_E_x0029_ | ***                  |
+-----------------------------------------+----------------------+
| ABC                                     | ***                  |
+-----------------------------------------+----------------------+
| Gerencia                                | ******               |
+-----------------------------------------+----------------------+
| Frecuencia de llamada                   | *********            |
+-----------------------------------------+----------------------+
| Ciudad                                  | *********            |
+-----------------------------------------+----------------------+
| Disponible1                             | *******              |
+-----------------------------------------+----------------------+
| Disponible2                             | *********            |
+-----------------------------------------+----------------------+


来源: stackexchange

问:
Kendo UI Window overlay opacity
How can I set overlay opacity with CSS. I tried  .k-overlay { opacity:0.9; } but it wont work. Can anyone help me? here I provide a simple demo

答: You could try <code>.k-overlay { opacity:0.9 !important; }</code> instead. That will override the setting which kendo applies directly to the overlay.  </p>

ContentLicense: CC BY-SA 4.0

Title: Kendo UI Window overlay opacity

Body: You could try .k-overlay { opacity:0.9 !important; } instead. That will override the setting which kendo applies directly to the overlay.


问:
What is the quickest way from a concept to a site?
I've got a bunch of website ideas and I was wondering what is the quickest way to get from a pretty thorough concept definition (idea mind-maps, use-cases, architecture diagrams ) to a working website. The only point is to get to something that's functional, not worrying about performance. The idea is to get something out to showcase a functional site, and after worry about fine-tuning or re-writing parts if necessary.

I am familiar with quite a few web frameworks from open-source and proprietary world, but I could not find so far a swiss-army-knife of web development environments that can get you fast from a concept to a working site.  I was kinda wondering if there is such a thing, free or non-free

Looking forward to your suggestions...

UPDATE: The question might get a bit too metaphoric for the kind readers of this site, but I'm at a moment where I feel that implementation details are killing my creativity ... maybe you'll laugh or you'll feel offended, I'm just wondering if anyone can give me a useful hint..

答: IMO, the quickest way from concept to a site is to actually build it (please read on). Choose an idea and build a simple site around it. While building it, keep other sites in mind, which will hopefully help you write highly reusable code. In reality, there is a lot of stuff you can  re-use: user login systems, data access layers (to a certain extent, of course) and other "common" parts. Once you write or buy some of these things, next sites will come much easier.</p>

OwnerDisplayName: Cip

ContentLicense: CC BY-SA 2.5


问:
Java : How to extract parameters from Google Dialogflow V2 response
Does anyone know how to extract the parameters returned by the Google dialogflow v2 response? I am able to get the intents and confidence properly as there are high level methods available to do so. But it seems there is no method to get the parameters/list of params. The response contains a google protobuf Struct that has the params. Does anyone know how to extract the parameter names and values from it.

Here is a sample response

```<code> query_text: "next friday"
parameters {
  fields {
    key: "appointmentDate"
    value {
      struct_value {
        fields {
          key: "date"
          value {
            string_value: "2019-05-31T12:00:00+10:00"
          }
        }
      }
    }
  }
}
all_required_params_present: true
fulfillment_messages {
  text {
    text: ""
  }
}
intent {
  name: "projects/dksjdkjsjksd-c824f/agent/intents/89a100c4973a"
  display_name: "captureDate"
}
intent_detection_confidence: 1.0
language_code: "en"
</code>```

答:
It would be something lilke this:</p>

```<code>            for (Entry<String, Value> entry : queryResult.getParameters().getFieldsMap().entrySet()) {
                if (entry.getValue().getKindCase().getNumber() == Value.STRING_VALUE_FIELD_NUMBER) {

                    log.debug("FOUND PARAM. KEY:" + entry.getKey() + " STRING VALUE: "
                            + entry.getValue().getStringValue());

                } else if (entry.getValue().getKindCase().getNumber() == Value.STRUCT_VALUE_FIELD_NUMBER) {

                    log.debug("FOUND PARAM. KEY:" + entry.getKey() + " STRUCT VALUE: "
                            + entry.getValue().getStructValue());

                }

                else if (entry.getValue().getKindCase().getNumber() == Value.NUMBER_VALUE_FIELD_NUMBER) {

                    log.debug("FOUND PARAM. KEY:" + entry.getKey() + " NUMBER VALUE: "
                            + String.valueOf(entry.getValue().getNumberValue()));

                }

            }
</code>```

Body:
Does anyone know how to extract the parameters returned by the Google dialogflow v2 response? I am able to get the intents and confidence properly as there are high level methods available to do so. But it seems there is no method to get the parameters/list of params. The response contains a google protobuf Struct that has the params. Does anyone know how to extract the parameter names and values from it.

Here is a sample response

 query_text: "next friday"
parameters {
  fields {
    key: "appointmentDate"
    value {
      struct_value {
        fields {
          key: "date"
          value {
            string_value: "2019-05-31T12:00:00+10:00"
          }
        }
      }
    }
  }
}
all_required_params_present: true
fulfillment_messages {
  text {
    text: ""
  }
}
intent {
  name: "projects/dksjdkjsjksd-c824f/agent/intents/89a100c4973a"
  display_name: "captureDate"
}
intent_detection_confidence: 1.0
language_code: "en"

Body:
It would be something lilke this:

            for (Entry<String, Value> entry : queryResult.getParameters().getFieldsMap().entrySet()) {
                if (entry.getValue().getKindCase().getNumber() == Value.STRING_VALUE_FIELD_NUMBER) {

                    log.debug("FOUND PARAM. KEY:" + entry.getKey() + " STRING VALUE: "
                            + entry.getValue().getStringValue());

                } else if (entry.getValue().getKindCase().getNumber() == Value.STRUCT_VALUE_FIELD_NUMBER) {

                    log.debug("FOUND PARAM. KEY:" + entry.getKey() + " STRUCT VALUE: "
                            + entry.getValue().getStructValue());

                }

                else if (entry.getValue().getKindCase().getNumber() == Value.NUMBER_VALUE_FIELD_NUMBER) {

                    log.debug("FOUND PARAM. KEY:" + entry.getKey() + " NUMBER VALUE: "
                            + String.valueOf(entry.getValue().getNumberValue()));

                }

            }


问:
Databases in central repository
I'm creating an application that helps staffs in my college to take attendance and term marks calculation in a easy way , for this I need my data to be stored in database in central place so that more than one staff(from different mobile) can access student details from their mobile. My knowledge is up to storing the data in local database using mysql .I have no idea how to make a central place to store the data.</p>

答:
you can create your app Firebase Realtime database or Firestore database:-

Firebase Realtime link :- https://firebase.google.com/docs/database

Firebase Firestore link :- https://firebase.google.com/docs/firestore/quickstart

you can use these 2 databases for your best experience if you don't have back-end team.

Title: Databases in central repository


问:
Render a list of foreign key in template

Models

class Head_of_department(models.Model):
    first_name = models.CharField(max_length=200)
    last_name = models.CharField(max_length=200)
    email = models.CharField(max_length=30)

    def __str__(self):
        return self.first_name

class Employee(models.Model):
    first_name = models.CharField(max_length=200, unique=True)
    last_name = models.CharField(max_length=200, unique=True)
    head_of_department = models.ForeignKey('Head_of_department', on_delete=models.SET_NULL, blank=True, null=True)
    email = models.EmailField(max_length=100)

     def __str__(self):
        return self.first_name + ' ' + self.last_name

class Attendance(models.Model):
    head_of_department = models.ForeignKey('Head_of_department', on_delete=models.SET_NULL, blank=True, null=True)
    employee = models.ForeignKey('Employee', on_delete=models.CASCADE, )
    attendance = models.CharField(max_length=8, choices=attendance_choices, blank=True)
```

<h3>Views</h3>

<pre class="lang-py prettyprint-override"><code>class Attendancecreate(CreateView):
    model = Attendance
    fields = ['employee']
    success_url = '/dashboard/'

    def get_context_data(self,** kwargs):
        context = super(Attendancecreate, self).get_context_data(**kwargs)
        email = self.request.user.email
        hod = Head_of_department.objects.get(email=email)
        context["objects"] = self.model.objects.filter(employee__head_of_department =hod)
        print (context["objects"])
        return context

     def form_valid(self, form):
        self.object = form.save(commit=False)
        self.object.head_of_department = get_object_or_404(Head_of_department, email=self.request.user.email)
        self.object.save()
        return super().form_valid(form)

</code>```

Template

        {% for item in objects %}
            {{ item.employee }}
        {% endfor %}

```

The webapp has a login feature. The headofdepartment can mark the attendance . I want to render a list of employees under the respective logged in HOD and mark attendance . I want to do this in the same view .

I am unable to render the employees for logged in HOD.

答:
I found the solution , I wrote views incorrectly.

    model = Attendance
    fields = ['employee']
    success_url = '/dashboard/'

    def get_context_data(self,** kwargs):
        context = super(Attendancecreate, self).get_context_data(**kwargs)
        email = self.request.user.email
        hod = Head_of_department.objects.get(email=email)
        context["objects"] = Employee.objects.filter(head_of_department =hod)
        print (context["objects"])
        return context
```

<h3>Template</h3>

<pre class="lang-html prettyprint-override"><code>
{% for emp in objects %}
            {{ emp.first_name }}  {{ emp.last_name }}
 {% endfor %}
</code>```

Body:
Models

class Head_of_department(models.Model):
    first_name = models.CharField(max_length=200)
    last_name = models.CharField(max_length=200)
    email = models.CharField(max_length=30)

    def __str__(self):
        return self.first_name

class Employee(models.Model):
    first_name = models.CharField(max_length=200, unique=True)
    last_name = models.CharField(max_length=200, unique=True)
    head_of_department = models.ForeignKey('Head_of_department', on_delete=models.SET_NULL, blank=True, null=True)
    email = models.EmailField(max_length=100)

     def __str__(self):
        return self.first_name + ' ' + self.last_name

class Attendance(models.Model):
    head_of_department = models.ForeignKey('Head_of_department', on_delete=models.SET_NULL, blank=True, null=True)
    employee = models.ForeignKey('Employee', on_delete=models.CASCADE, )
    attendance = models.CharField(max_length=8, choices=attendance_choices, blank=True)

Views

class Attendancecreate(CreateView):
    model = Attendance
    fields = ['employee']
    success_url = '/dashboard/'

    def get_context_data(self,** kwargs):
        context = super(Attendancecreate, self).get_context_data(**kwargs)
        email = self.request.user.email
        hod = Head_of_department.objects.get(email=email)
        context["objects"] = self.model.objects.filter(employee__head_of_department =hod)
        print (context["objects"])
        return context

     def form_valid(self, form):
        self.object = form.save(commit=False)
        self.object.head_of_department = get_object_or_404(Head_of_department, email=self.request.user.email)
        self.object.save()
        return super().form_valid(form)

Template

        {% for item in objects %}
            {{ item.employee }}
        {% endfor %}

The webapp has a login feature. The headofdepartment can mark the attendance . I want to render a list of employees under the respective logged in HOD and mark attendance . I want to do this in the same view .

I am unable to render the employees for logged in HOD.

Body:
I found the solution , I wrote views incorrectly.

    model = Attendance
    fields = ['employee']
    success_url = '/dashboard/'

    def get_context_data(self,** kwargs):
        context = super(Attendancecreate, self).get_context_data(**kwargs)
        email = self.request.user.email
        hod = Head_of_department.objects.get(email=email)
        context["objects"] = Employee.objects.filter(head_of_department =hod)
        print (context["objects"])
        return context

Template

{% for emp in objects %}
            {{ emp.first_name }}  {{ emp.last_name }}
 {% endfor %}


问:
Using RDS instead of mysql containers in kubernetes
I used this tutorial to install wordpress using kubernetes.

https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/

It is working as expected. But I will prefer to use Amazon RDS instead of mysql pods. I am not sure what changes are required.

答:
In the wordpress deployment you just need to update the host and credentials for your amazon db

you don't need to deploy any of the mysql resources from the tutorial.


问:
How to Select between two periode of month and year eg: january 2018 - january 2019?
SQL query problem</p>

```<code>select *
from app_contract_hd
where year(created_datetime) between 2018 and 2018 and MONTH(created_datetime)between 4 and 4
</code>```

答:
You can try simple code:</p>

```<code>select *
from app_contract_hd
where '2018-01-01' <= created_datetime and created_datetime < '2019-02-01'
</code>```

Body:
SQL query problem

select *
from app_contract_hd
where year(created_datetime) between 2018 and 2018 and MONTH(created_datetime)between 4 and 4

Body:
You can try simple code:

select *
from app_contract_hd
where '2018-01-01' <= created_datetime and created_datetime < '2019-02-01'


问:
Flutter card top radius is covered by Image
When I add a image to the card, the Radius  at the top of the card are covered. How can I solve it?

When I add a image to the card, the Radius  at the top of the card are covered. How can I solve it?

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(primarySwatch: Colors.yellow),
      home: Scaffold(
          backgroundColor: Colors.grey[200],
          appBar: AppBar(title: Text('Demo'),),
          body: SizedBox(
              height: 310.0,
              child: Card(
                elevation: 3.0,
                color: Colors.white,
                margin: EdgeInsets.all(8.0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    SizedBox(height: 0.0,),
                    Image.network('https://img.zcool.cn/community/012157578c405f0000012e7e69e7cd.jpg@1280w_1l_2o_100sh.jpg'),
                    SizedBox(height: 16.0,),
                    Row(
                      children: <Widget>[
                        SizedBox(width: 16.0,),
                        Text('素雪', style: Theme.of(context).textTheme.headline,),
                        SizedBox(width: 16.0,),
                        Text('吉时已到', style: Theme.of(context).textTheme.subhead,),
                      ],
                    ),
                    SizedBox(height: 16.0,),
                  ],
                ),
              ))),
    );
  }
}
```

This is the rendering

答:
You can put the image in Material and set the Border Radius and Clip Behaviour.

```<code>    Material(
            color: Colors.white,
            borderRadius: BorderRadius.circular(10.0),
            elevation: 2.0,
            clipBehavior: Clip.antiAliasWithSaveLayer,
            type: MaterialType.transparency,
            child: Image.asset(
              "images/user.png",
              height: 150,
              width: double.infinity,
              fit: BoxFit.cover,
            ),
          ),
</code>```

Body:
When I add a image to the card, the Radius  at the top of the card are covered. How can I solve it?

When I add a image to the card, the Radius  at the top of the card are covered. How can I solve it?

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(primarySwatch: Colors.yellow),
      home: Scaffold(
          backgroundColor: Colors.grey[200],
          appBar: AppBar(title: Text('Demo'),),
          body: SizedBox(
              height: 310.0,
              child: Card(
                elevation: 3.0,
                color: Colors.white,
                margin: EdgeInsets.all(8.0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    SizedBox(height: 0.0,),
                    Image.network('https://img.zcool.cn/community/012157578c405f0000012e7e69e7cd.jpg@1280w_1l_2o_100sh.jpg'),
                    SizedBox(height: 16.0,),
                    Row(
                      children: <Widget>[
                        SizedBox(width: 16.0,),
                        Text('素雪', style: Theme.of(context).textTheme.headline,),
                        SizedBox(width: 16.0,),
                        Text('吉时已到', style: Theme.of(context).textTheme.subhead,),
                      ],
                    ),
                    SizedBox(height: 16.0,),
                  ],
                ),
              ))),
    );
  }
}

This is the rendering

Body:
You can put the image in Material and set the Border Radius and Clip Behaviour.

    Material(
            color: Colors.white,
            borderRadius: BorderRadius.circular(10.0),
            elevation: 2.0,
            clipBehavior: Clip.antiAliasWithSaveLayer,
            type: MaterialType.transparency,
            child: Image.asset(
              "images/user.png",
              height: 150,
              width: double.infinity,
              fit: BoxFit.cover,
            ),
          ),


问:
ActsAsTenant current_tenant + Capybara + RSpec testing
I am trying to create an integration test with Capybara/RSpec that has a valid current_user (using the Warden.test_mode! trick) and I have also created a valid current_tenant by doing this in the test:

```<code>ActsAsTenant.current_tenant = Account.first
</code>```

When the test is ran it comes up with a "undefined method for nil:NilClass" error that is characteristic of the current_tenant not being set. I have verified that Account.first does in fact have what I expect in it.

What might be the problem and how can I fix it?

答:
You can check the gem 'act_as_tent' doc over here
https://github.com/ErwinM/acts_as_tenant#testing</p>

ContentLicense: CC BY-SA 3.0

Body:
I am trying to create an integration test with Capybara/RSpec that has a valid current_user (using the Warden.test_mode! trick) and I have also created a valid current_tenant by doing this in the test:

ActsAsTenant.current_tenant = Account.first

When the test is ran it comes up with a "undefined method for nil:NilClass" error that is characteristic of the current_tenant not being set. I have verified that Account.first does in fact have what I expect in it.

What might be the problem and how can I fix it?


问:
Why does performance drop when a function is moved to another module?
I am observing that the same fn gives different performance, depending on whether it's placed in the same module where it's used or in a module next to it. Any ideas what could be causing it?

Here's the function:
https://github.com/oshyshko/polymodperf/blob/master/src/Main.hs#L41-L55

```<code>test :: MArray a t m => (t -> t) -> a Int t -> m ()
test f a =
    mapM_ (\ xy -> do
              v <- get a xy
              set a xy (f v))

          [ (x,y) | y <- [0..1000 - 1],
                    x <- [0..1000 - 1],
                    n <- [0..10]]
  where
    get :: MArray a e m => a Int e -> (Int, Int) -> m e
    get a (x,y) = readArray a (x + y * 1000)

    set :: MArray a e m => a Int e -> (Int, Int) -> e -> m ()
    set a (x,y) = writeArray a (x + y * 1000)
</code>```

In my test pass I use Data.Array.IO.newArray to create an array, then pass it to test.

Here's how to observe the difference in performance (second value, ms):

```<code>$ ./scripts/build-exec.sh
...
Main.test
(11000000,2010)
(11000000,239)
(11000000,240)
(11000000,242)
(11000000,237)

SomeModule.test
(11000000,6376)
(11000000,4851)
(11000000,5455)
(11000000,5096)
(11000000,5206)
</code>```

Main.test: both newArray and test both live in Main => okay performance (the first 2010ms run is probably bad due to warmup, but the rest look good)

SomeModule.test: newArray lives in Main, but test is imported from SomeModule.test => much worse performance

The code of test is identical in both modules:
https://github.com/oshyshko/polymodperf/blob/master/src/Main.hs#L41-L55
https://github.com/oshyshko/polymodperf/blob/master/src/SomeModule.hs#L9-L17

The used MArray typeclass and fns readArray, writeArray imported from the same module in both cases:

```<code>import           Data.Array.MArray (MArray, readArray, writeArray)
</code>```

Any ideas what could be causing the difference in performance?

答:
As leftaroundabout suggested in a comment, adding INLINE pragma solved the problem:

```<code>test :: MArray a t m => (t -> t) -> a Int t -> m ()
{-# INLINE test #-}
test f a =
    ...
</code>```

https://github.com/oshyshko/polymodperf/blob/master/src/SomeModule.hs#L10

Body:
I am observing that the same fn gives different performance, depending on whether it's placed in the same module where it's used or in a module next to it. Any ideas what could be causing it?

Here's the function:
https://github.com/oshyshko/polymodperf/blob/master/src/Main.hs#L41-L55

test :: MArray a t m => (t -> t) -> a Int t -> m ()
test f a =
    mapM_ (\ xy -> do
              v <- get a xy
              set a xy (f v))

          [ (x,y) | y <- [0..1000 - 1],
                    x <- [0..1000 - 1],
                    n <- [0..10]]
  where
    get :: MArray a e m => a Int e -> (Int, Int) -> m e
    get a (x,y) = readArray a (x + y * 1000)

    set :: MArray a e m => a Int e -> (Int, Int) -> e -> m ()
    set a (x,y) = writeArray a (x + y * 1000)

In my test pass I use Data.Array.IO.newArray to create an array, then pass it to test.

Here's how to observe the difference in performance (second value, ms):

$ ./scripts/build-exec.sh
...
Main.test
(11000000,2010)
(11000000,239)
(11000000,240)
(11000000,242)
(11000000,237)

SomeModule.test
(11000000,6376)
(11000000,4851)
(11000000,5455)
(11000000,5096)
(11000000,5206)

Main.test: both newArray and test both live in Main => okay performance (the first 2010ms run is probably bad due to warmup, but the rest look good)

SomeModule.test: newArray lives in Main, but test is imported from SomeModule.test => much worse performance

The code of test is identical in both modules:
https://github.com/oshyshko/polymodperf/blob/master/src/Main.hs#L41-L55
https://github.com/oshyshko/polymodperf/blob/master/src/SomeModule.hs#L9-L17

The used MArray typeclass and fns readArray, writeArray imported from the same module in both cases:

import           Data.Array.MArray (MArray, readArray, writeArray)

Any ideas what could be causing the difference in performance?

Body:
As leftaroundabout suggested in a comment, adding INLINE pragma solved the problem:

test :: MArray a t m => (t -> t) -> a Int t -> m ()
{-# INLINE test #-}
test f a =
    ...

https://github.com/oshyshko/polymodperf/blob/master/src/SomeModule.hs#L10


问:
Python GCP-API permissions issue: compute.instances.list
I have a 5 line Python script which is failing.

GCP indicates a problem with a GCP-API permissions issue.
I'm not sure though it is telling me the truth.

Here is the Python syntax:

```<code>import googleapiclient.discovery
compute   = googleapiclient.discovery.build('compute', 'v1')
project_s = 'shining-sol-241621'
zone_s    = 'us-central1-a'

result = compute.instances().list(project=project_s, zone=zone_s).execute()
</code>```

The above syntax depends on this env variable setting:

```<code>export GOOGLE_APPLICATION_CREDENTIALS=$HOME/secret.json
</code>```

When I run the Python syntax I see:

```<code>$ python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import googleapiclient.discovery
>>> compute   = googleapiclient.discovery.build('compute', 'v1')
>>> project_s = 'shining-sol-241621'
>>> zone_s    = 'us-central1-a'
>>> result = compute.instances().list(project=project_s, zone=zone_s).execute()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/googleapiclient/http.py", line 851, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/compute/v1/projects/shining-sol-241621/zones/us-central1-a/instances?alt=json returned "Required 'compute.instances.list' permission for 'projects/shining-sol-241621'">
>>> >>>
</code>```

Above, I see this msg in the error:

"Required 'compute.instances.list' permission for 'projects/shining-sol-241621'"

At this URL:

https://console.cloud.google.com/iam-admin/iam?project=shining-sol-241621

When I look at the service-account permissions attached to my secret.json file I see that I have attached these permissions to the account:

Compute Admin

Compute Instance Admin (beta)

Compute Instance Admin (v1)

Compute Viewer

Security Admin

Owner

When I attached permissions to the service-account, I saw no permission available which looked like:
'compute.instances.list'

I did note that the Compute Admin permission has this description:

"Full control of all Compute Engine resources"

That description suggests to me that the permission should be able to do: 'compute.instances.list'

I am suspicious that GCP is telling me that I have a permissions problem but the problem is somewhere else.

Based on my description, what would be some good questions to ask in order to move past this bad API behavior?

答:
I was able to fix this problem after I assumed that the GCP server was caching bad info.

I created a service account with a name I had not used in the past.

I gave it just one permission: Project - Owner

I asked it to create a JSON-key.

I copied the key into $HOME/secret.json

I issued shell command:

```<code>export GOOGLE_APPLICATION_CREDENTIALS=$HOME/secret.json
</code>```

I tried my 6 lines of Python:

```<code>$ python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import googleapiclient.discovery
>>> compute   = googleapiclient.discovery.build('compute', 'v1')
>>> project_s = 'shining-sol-241621'
>>> zone_s    = 'us-central1-a'
>>> result = compute.instances().list(project=project_s, zone=zone_s).execute()
>>> result['items'][0]['status']
'RUNNING'
>>>
>>>
</code>```

As you can see, it worked.
Yay!

Body:
I have a 5 line Python script which is failing.

GCP indicates a problem with a GCP-API permissions issue.
I'm not sure though it is telling me the truth.

Here is the Python syntax:

import googleapiclient.discovery
compute   = googleapiclient.discovery.build('compute', 'v1')
project_s = 'shining-sol-241621'
zone_s    = 'us-central1-a'

result = compute.instances().list(project=project_s, zone=zone_s).execute()

The above syntax depends on this env variable setting:

export GOOGLE_APPLICATION_CREDENTIALS=$HOME/secret.json

When I run the Python syntax I see:

$ python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import googleapiclient.discovery
>>> compute   = googleapiclient.discovery.build('compute', 'v1')
>>> project_s = 'shining-sol-241621'
>>> zone_s    = 'us-central1-a'
>>> result = compute.instances().list(project=project_s, zone=zone_s).execute()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/googleapiclient/http.py", line 851, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/compute/v1/projects/shining-sol-241621/zones/us-central1-a/instances?alt=json returned "Required 'compute.instances.list' permission for 'projects/shining-sol-241621'">
>>> >>>

Above, I see this msg in the error:

"Required 'compute.instances.list' permission for 'projects/shining-sol-241621'"

At this URL:

https://console.cloud.google.com/iam-admin/iam?project=shining-sol-241621

When I look at the service-account permissions attached to my secret.json file I see that I have attached these permissions to the account:

Compute Admin

Compute Instance Admin (beta)

Compute Instance Admin (v1)

Compute Viewer

Security Admin

Owner

When I attached permissions to the service-account, I saw no permission available which looked like:
'compute.instances.list'

I did note that the Compute Admin permission has this description:

"Full control of all Compute Engine resources"

That description suggests to me that the permission should be able to do: 'compute.instances.list'

I am suspicious that GCP is telling me that I have a permissions problem but the problem is somewhere else.

Based on my description, what would be some good questions to ask in order to move past this bad API behavior?

Body:
I was able to fix this problem after I assumed that the GCP server was caching bad info.

I created a service account with a name I had not used in the past.

I gave it just one permission: Project - Owner

I asked it to create a JSON-key.

I copied the key into $HOME/secret.json

I issued shell command:

export GOOGLE_APPLICATION_CREDENTIALS=$HOME/secret.json

I tried my 6 lines of Python:

$ python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import googleapiclient.discovery
>>> compute   = googleapiclient.discovery.build('compute', 'v1')
>>> project_s = 'shining-sol-241621'
>>> zone_s    = 'us-central1-a'
>>> result = compute.instances().list(project=project_s, zone=zone_s).execute()
>>> result['items'][0]['status']
'RUNNING'
>>>
>>>

As you can see, it worked.
Yay!


问:
Why isn't __bases__ accessible in the class body?
Class objects have a __bases__ (and a __base__) attribute:

```<code>>>> class Foo(object):
...     pass
...
>>> Foo.__bases__
(<class 'object'>,)
</code>```

Sadly, these attributes aren't accessible in the class body, which would be very convenient for accessing parent class attributes without having to hard-code the name:

```<code>class Foo:
    cls_attr = 3

class Bar(Foo):
    cls_attr = __base__.cls_attr + 2
    # throws NameError: name '__base__' is not defined
</code>```

Is there a reason why __bases__ and __base__ can't be accessed in the class body?

(To be clear, I'm asking if this is a conscious design decision. I'm not asking about the implementation; I know that __bases__ is a descriptor in type and that this descriptor can't be accessed until a class object has been created. I want to know why python doesn't create __bases__ as a local variable in the class body.)

答:
I want to know why python doesn't create __bases__ as a local variable in the class body

As you know, class is mostly a shortcut for type.__new__() - when the runtime hits a class statements, it executes all statements at the top-level of the class body, collects all resulting bindings in a dedicated namespace dict, calls type() with the concrete metaclass, the class name, the base classes and the namespace dict, and binds the resulting class object to the class name in the enclosing scope (usually but not necessarily the module's top-level namespace).

The important point here is that it's the metaclass responsabilty to build the class object, and to allow for class object creation customisations, the metaclass must be free to do whatever it wants with its arguments. Most often a custom metaclass will mainly work on the attrs dict, but it must also be able to mess with the bases argument. Now since the metaclass is only invoked AFTER the class body statements have been executed, there's no way the runtime can reliably expose the bases in the class body scope since those bases could be modified afterward by the metaclass.

There are also some more philosophical considerations here, notably wrt/ explicit vs implicit, and as shx2 mentions, Python designers try to avoid magic variables popping out of the blue. There are indeed a couple implementation variables (__module__ and, in py3, __qualname__) that are "automagically" defined in the class body namespace, but those are just names, mostly intended as  additional debugging / inspection informations for developers)  and have absolutely no impact on the class object creation nor on its properties, behaviour and whatnots.

As always with Python, you have to consider the whole context (the execution model, the object model, how the different parts work together etc) to really understand the design choices. Whether you agree with the whole design and philosophy is another debate (and one that doesn't belong here), but you can be sure that yes, those choices are "conscious design decisions".

Body:
Class objects have a __bases__ (and a __base__) attribute:

>>> class Foo(object):
...     pass
...
>>> Foo.__bases__
(<class 'object'>,)

Sadly, these attributes aren't accessible in the class body, which would be very convenient for accessing parent class attributes without having to hard-code the name:

class Foo:
    cls_attr = 3

class Bar(Foo):
    cls_attr = __base__.cls_attr + 2
    # throws NameError: name '__base__' is not defined

Is there a reason why __bases__ and __base__ can't be accessed in the class body?

(To be clear, I'm asking if this is a conscious design decision. I'm not asking about the implementation; I know that __bases__ is a descriptor in type and that this descriptor can't be accessed until a class object has been created. I want to know why python doesn't create __bases__ as a local variable in the class body.)


问:
how to pass model data to policy class from blade file
Hello i'm facing a problem of laravel, gate,i'm trying to pass Model class data to the gate function and check some data of the model class.
but problem is can't pass the model to gate function from the blade file.

this is my model,AuthServiceProviderand view file code.

view.blade.php

```<code> @can('create-role',permission::class)
                 <div class="text-center">
                    <a href="" class="btn btn-success btn-rounded mb-
                     4">Add</a>
                    </div>
                @endcan
</code>```

AuthServiceProvider.php

```<code>    Gate::define('create-role', function ( $permissionrole) {
    $id = Auth::user()->id;
         $permissionid = 1;

        foreach ($permissionrole as $value) {
      if($value->user_id == $id && $value->permisions_id == $permissionid)
            {
                return  true;
            }
            return false;
        }
        });
}
</code>```

Model file

```<code>  protected $table = 'permissions';
  protected $primaryKey  = 'permission_id';
  protected $fillable = [
  name','for',];
  public $incrementing = false;
</code>```

答:
you should pass the permission model instead of permission::class in the @can directive ; then you have access to it:

```<code>      Gate::define('create-role', function ( $permission) {
      $id = Auth::user()->id;
      $permissionid = 1;

      //your checking goes here
      });
</code>```

Body:
Hello i'm facing a problem of laravel, gate,i'm trying to pass Model class data to the gate function and check some data of the model class.
but problem is can't pass the model to gate function from the blade file.

this is my model,AuthServiceProviderand view file code.

view.blade.php

 @can('create-role',permission::class)

                    Add

                @endcan

AuthServiceProvider.php

    Gate::define('create-role', function ( $permissionrole) {
    $id = Auth::user()->id;
         $permissionid = 1;

        foreach ($permissionrole as $value) {
      if($value->user_id == $id && $value->permisions_id == $permissionid)
            {
                return  true;
            }
            return false;
        }
        });
}

Model file

  protected $table = 'permissions';
  protected $primaryKey  = 'permission_id';
  protected $fillable = [
  name','for',];
  public $incrementing = false;

Body:
you should pass the permission model instead of permission::class in the @can directive ; then you have access to it:

      Gate::define('create-role', function ( $permission) {
      $id = Auth::user()->id;
      $permissionid = 1;

      //your checking goes here
      });


问:
How to get city and state name in Autocomplete Places _ Places API
Iam using Places Autocomplete for selecting city from user, its working fine,
But now i want both city and state name..
my code..

Initialising

```<code>  List<Place.Field> fields = Arrays.asList(Place.Field.ID, Place.Field.NAME);
            Intent intent = new Autocomplete.IntentBuilder(
                    AutocompleteActivityMode.OVERLAY, fields)
                    .setTypeFilter(TypeFilter.CITIES)
                    .setCountry("IN")
                    .build(this);
            startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE);
</code>```

onActivity Result

```<code>if (requestCode == AUTOCOMPLETE_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                //Place place = Autocomplete.getPlaceFromIntent(data);
                Place place = Autocomplete.getPlaceFromIntent(data);

                edit_profile_city_editText.setText(place.getName());

            } else if (resultCode == AutocompleteActivity.RESULT_ERROR) {
                Status status = Autocomplete.getStatusFromIntent(data);
                Log.i("Autocomplete error", status.getStatusMessage());
            } else if (resultCode == RESULT_CANCELED) {
            }
        }
</code>```

While selecting city from search bar its showing both city and state..
eg:Chennai
TamilNadu, India
Kindly help how to get state name also...

答:
I think these will work for you;

```<code>Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(MyLat, MyLong, 1);
String cityName = addresses.get(0).getAddressLine(0);
String stateName = addresses.get(0).getAddressLine(1);
String countryName = addresses.get(0).getAddressLine(2);
</code>```

or

```<code>String address = addresses.get(0).getSubLocality();
String cityName = addresses.get(0).getLocality();
String stateName = addresses.get(0).getAdminArea();
</code>```

Body:
Iam using Places Autocomplete for selecting city from user, its working fine,
But now i want both city and state name..
my code..

Initialising

  List<Place.Field> fields = Arrays.asList(Place.Field.ID, Place.Field.NAME);
            Intent intent = new Autocomplete.IntentBuilder(
                    AutocompleteActivityMode.OVERLAY, fields)
                    .setTypeFilter(TypeFilter.CITIES)
                    .setCountry("IN")
                    .build(this);
            startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE);

onActivity Result

if (requestCode == AUTOCOMPLETE_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                //Place place = Autocomplete.getPlaceFromIntent(data);
                Place place = Autocomplete.getPlaceFromIntent(data);

                edit_profile_city_editText.setText(place.getName());

            } else if (resultCode == AutocompleteActivity.RESULT_ERROR) {
                Status status = Autocomplete.getStatusFromIntent(data);
                Log.i("Autocomplete error", status.getStatusMessage());
            } else if (resultCode == RESULT_CANCELED) {
            }
        }

While selecting city from search bar its showing both city and state..
eg:Chennai
TamilNadu, India
Kindly help how to get state name also...

Body:
I think these will work for you;

Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(MyLat, MyLong, 1);
String cityName = addresses.get(0).getAddressLine(0);
String stateName = addresses.get(0).getAddressLine(1);
String countryName = addresses.get(0).getAddressLine(2);

or

String address = addresses.get(0).getSubLocality();
String cityName = addresses.get(0).getLocality();
String stateName = addresses.get(0).getAdminArea();


问:
What is php's performance on directly accessing array's row with key specified
I have a question regarding array's performance.... how does php handle array keys? I mean if I do something like $my_city = $cities[15]; .... does php directly access the exact row item in $cities array or does php iterate trough array until it finds the matched row?

and if it access the row directly... is there a difference in performance between an array with 100 rows and array with 100,000 rows?

like in this example
$my_city = $cities[15];

答: there is always an obvious difference in performance between an array with 100 rows and array with 100,000 rows</p>


问:
Numbering of sub-llists with GitHub-markdown
I want to create a list like that.

```<code> - one
 - two
  1. sub-one
  2. sub-two
     1. sub-sub-one
     2. sub-sub-two
</code>```

But markdown (on GitHub) use i, ii, ... and for the sub-list and a, b, c, ... for the sub-sub-list.

How can I modify this behaviour with that markdown-code.

```<code>  # one
  # two
    1) sub-one
    2) sub-two
     1) sub-sub-one
     2) sub-sub-two
</code>```

答:
Markdown itself can not do that.

But some workarounds can be found in the duplicate question How do you make lettered lists using markdown?.

Body:
I want to create a list like that.

 - one
 - two
  1. sub-one
  2. sub-two
     1. sub-sub-one
     2. sub-sub-two

But markdown (on GitHub) use i, ii, ... and for the sub-list and a, b, c, ... for the sub-sub-list.

How can I modify this behaviour with that markdown-code.

  # one
  # two
    1) sub-one
    2) sub-two
     1) sub-sub-one
     2) sub-sub-two