English 中文(简体)
5. 彩虹问题
原标题:SQL Server Xml Namespace Querying Problem

页: 1

<EntityKey_x005B__x005D_>
  <EntityKey>
    <KeyData xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
      <KeyField>
        <Field>JournalNum</Field>
        <Value>LJRN000071</Value>
      </KeyField>
    </KeyData>
  </EntityKey>
  <EntityKey>
    <KeyData xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
      <KeyField>
        <Field>JournalNum</Field>
        <Value>LJRN000072</Value>
      </KeyField>
    </KeyData>
  </EntityKey>
  <EntityKey>
    <KeyData xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
      <KeyField>
        <Field>JournalNum</Field>
        <Value>LJRN000073</Value>
      </KeyField>
    </KeyData>
  </EntityKey>
  <EntityKey>
    <KeyData xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
      <KeyField>
        <Field>JournalNum</Field>
        <Value>LJRN000074</Value>
      </KeyField>
    </KeyData>
  </EntityKey>
</EntityKey_x005B__x005D_>

但是,由于<条码>xmlns=......,我似乎无法从中选择《日刊》的数值。 在互联网上,我可以做一些事情,如<条码>{>。 http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey}KeyData“,以检索,但我在LQ中发现一个星号错误。

我只想获得一份价值节点清单,以便列入一个温床,而这要么没有工作。

SELECT  IDENTITY(int,1,1) as  ID ,
    c.query( (KeyData/KeyField/Value)[1] ) as  JournalNum 
INTO    #tmpBatches
FROM    @ResultData.nodes( //EntityKey ) t(c)

想法? 建议 解决办法?

最佳回答

......当然,在提出要求后正确

    ;WITH XMLNAMESPACES (N http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey  as DYN)
    SELECT  IDENTITY(int,1,1)   
                as  ID ,
            c.value( (DYN:KeyData/DYN:KeyField/DYN:Value)[1] ,  VARCHAR(40) )
                as  JournalNum 
    INTO    #tmpBatches
    FROM    @ResultData.nodes( //EntityKey ) t(c)
问题回答

由于你只有一个名字空间,你本可以利用儿童之友协会避免在任何地方预先确定:

 ;WITH XMLNAMESPACES (DEFAULT N http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey ) 
        SELECT   IDENTITY(int,1,1)                                                
        as  ID , c.value( (<strike>DYN:</strike>KeyData/DYN:KeyField/DYN:Value)[1] ,  VARCHAR(40) )
        as  JournalNum 
            INTO #tmpBatches
        FROM @ResultData.nodes( //EntityKey ) t(c)

Also, some notes I stumbled across on how to ignore all namespaces for when there are more than one and you KNOW you will have no collisions. Someone s blog.





相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签