DECLARE @idoc int EXEC sp_xml_preparedocument @idoc OUTPUT, ' <A ID="1"> <B>this is elementB</B> </A>' SELECT * FROM OPENXML (@idoc, 'A/B',0) WITH ( curid varchar(20) '@mp:id', parid varchar(20) '@mp:parentid' ) EXEC sp_xml_removedocument @idoc
可被选择的Meta Property有:
@mp:id
Provides system-generated, document-wide identifier of the DOM node. An XML ID of 0 indicates that the element is a root element and its @mp:parentid is NULL.
@mp:parentid
Same as @mp:id, only for the parent.
@mp:localname
Provides the non-fully qualified name of the node. It is used with prefix and namespace URI to name element or attribute nodes.
@mp:parentlocalname
Same as @mp:localname, only for the parent.
@mp:namespaceuri
Provides the namespace URI of the current element. If the value of this attribute is NULL, no namespace is present.
@mp:parentnamespaceuri
Same as @mp:namespaceuri, only for the parent.
@mp:prefix
The namespace prefix of the current element name.
@mp:prev
Stores the @mp:id of the previous sibling relative to a node. Using this, we can tell something about the ordering of the elements at the current level of the hierarchy.
@mp:xmltext
This Meta property is used for processing purposes, and contains the actual XML text for the current element as used in the overflow handling of OPENXML.
DECLARE @idoc int EXEC sp_xml_preparedocument @idoc OUTPUT, ' <A B="1"> <B>this is elementB</B> </A>' SELECT * FROM OPENXML (@idoc, 'A',1) WITH ( B varchar(20) ) SELECT * FROM OPENXML (@idoc, 'A',2) WITH ( B varchar(20) ) EXEC sp_xml_removedocument @idoc