Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Sql Server ¶ÔxmlÀàÐ͵IJÙ×÷

 declare @XML XML
SET @XML='<root>
 <OLDVALUE>
  <H_Action id="1130">030</H_Action>
  <D_Action>030</D_Action>
  <OrderCompany>00220</OrderCompany>
  <OrderNumber>10004035</OrderNumber>
  <OrderType>SO</OrderType>
  <LineNumber>10.100</LineNumber>
 </OLDVALUE>
 <NEWVALUE>
  <H_Action>040</H_Action>
  <D_Action>040</D_Action>
  <OrderCompany>00220</OrderCompany>
  <OrderNumber>10004035</OrderNumber>
  <OrderType>SO</OrderType>
  <LineNumber>10.100</LineNumber>
  <LineType>CS</LineType>
  <LoadNumber>8811</LoadNumber>
 </NEWVALUE>
</root>'
select c.value('H_Action[1]','varchar(20)') as H_Action,
c.value('D_Action[1]','varchar(20)') as D_Action,
c.value('OrderCompany[1]','varchar(20)') as OrderCompany,
c.value('OrderNumber[1]','varchar(20)') as OrderNumber,
c.value('OrderType[1]','varchar(20)') as OrderType,
c.value('LineNumber[1]','varchar(20)') as LineNumber
from @XML.nodes('//OLDVALUE') as T(C)
select c.value('H_Action[1]','varchar(20)') as H_Action,
c.value('D_Action[1]','varchar(20)') as  D_Action,
c.value('OrderCompany[1]','varchar(20)') as OrderCompany,
c.value('OrderNumber[1]','varchar(20)') as OrderNumber,
c.value('OrderType[1]','varchar(20)') as OrderType,
c.value('LineNumber[1]','varchar(20)') as LineNumber,
c.value('LineType[1]','varchar(20)') as LineType,
c.value('LoadNumber[1]','varchar(20)') as LoadNumber
from @XML.nodes('//NEWVALUE') as T(C)
CREATE TABLE [dbo].[T_XML](
 [ID] [int] NULL,
 [DOC] [xml] NULL
)
--query
select doc.query('//NEWVALUE') from t_xml
select doc.query('(root/OLDVALUE/H_Action[@id="1130"])') from t_xml
--


Ïà¹ØÎĵµ£º

C# XmlÖÐÓ³ÉäΪÀàÊý¾Ý½á¹¹£¨±¨ÎÄ£©

        [System.Runtime.Serialization.DataMemberAttribute()]
        public Information Archive {
            get {
         &n ......

XML·Ö½âʵÀý

Ô­Ìù: http://topic.csdn.net/u/20100414/11/c69748ac-e0b2-490f-bde9-7c5284c3660c.html?seed=1832202493
 
declare @xml xml=
'<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/UpdateHandlers/Command ......

XML²éѯ×Ó½ÚµãµÄ·½·¨

   ¶ÔXmlµÄ½Úµã½øÐмòµ¥²éѯµÄʱºò£¬³£ÓõĿÉÒÔʹÓÃÈçÏ·½·¨£º
(1) XmlNode node = doc.selectSingleNode("//AllNode/Node[@ID = ’aaa’]");
ÔÚÕû¸öXmlÖвéÕÒAllNode½ÚµãϵĽڵãÃûΪNodeµÄ½Úµã£¬¸Ã×Ó½ÚµãµÄIDÊôÐÔֵΪaaa
(2)XmlNode node = doc.selectSingleNode("//AllNode /*[@ID = ’aaa& ......

XPath,XMLÎĵµ,SelectNodes()ͨÅä·û˵Ã÷


ÀûÓÃXPath¶ÁÈ¡XmlÎļþ
Ö®ËùÒÔÒªÒýÈëXPathµÄ¸ÅÄĿµÄ¾ÍÊÇΪÁËÔÚÆ¥ÅäXMLÎĵµ½á¹¹Ê÷ʱÄܹ»×¼È·µØÕÒµ½Ä³Ò»¸ö½ÚµãÔªËØ¡£¿ÉÒÔ°ÑXPath±È×÷Îļþ¹ÜÀí·¾¶£ºÍ¨¹ýÎļþ¹ÜÀí·¾¶£¬¿ÉÒÔ°´ÕÕÒ»¶¨µÄ¹æÔò²éÕÒµ½ËùÐèÒªµÄÎļþ£»Í¬Ñù£¬ÒÀ¾ÝXPathËùÖƶ¨µÄ¹æÔò£¬Ò²¿ÉÒԺܷ½±ãµØÕÒµ½XML½á¹¹ÎĵµÊ÷ÖеÄÈκÎÒ»¸ö½Úµã.
¡¡¡¡²»¹ý£¬ÓÉÓÚXPath¿ÉÓ¦Ó ......

Õë¶Ô¸Ã¼Ü¹¹½øÐеĹ淶XMLÑé֤ʧ°Ü

ÔÚAccess2007ÖдÓExcelµ¼Èëʱ£¬¾­³£»áÅöµ½ÈçϵĴíÎóÌáʾ£º“Õë¶Ô¸Ã¼Ü¹¹½øÐеĹ淶XMLÑé֤ʧ°Ü¡£ÒÔÏÂXMLÎĵµÐÐÖдæÔÚ´íÎ󣺣ü¡£”
ÎҵĽâ¾ö·½Ê½ÊÇÓÃÁ´½Ó±í·½Ê½À´´ò¿ªExcelÎļþ£¬È»ºóÔÚ¸´ÖÆÁ´½Ó±í£¬Õ³Ìù¡£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ