XML ,query 和 value是区分大小写 的
DECLARE @x xml
SET @x='
<root>
<ShopAccount>
<ActivityType>IA - PM Standing WO (for LPI report)</ActivityType>
<ProjectNo>R</ProjectNo>
</ShopAccount>
<ShopAccount>
<ActivityType>IX - PM Associated WO (for LPI report)</ActivityType>
<ProjectNo>C</ProjectNo>
</ShopAccount>
</root>'
SELECT
ROW_NUMBER() OVER (order by T.c.value('ActivityType[1]','nvarchar(255)')) AS ROWID,
T.c.value('ActivityType[1]','nvarchar(255)') AS ActivityType
,T.c.value('ProjectNo[1]','nvarchar(255)') AS ProjectNo
from @x.nodes('/root/ShopAccount') T(c)
SELECT
ROW_NUMBER() OVER (order by T.c.query('ActivityType').value('ActivityType[1]','nvarchar(255)')) AS ROWID,
T.c.query('ActivityType').value('ActivityType[1]','nvarchar(255)') AS ActivityType
,T.c.query('ProjectNo').value('ProjectNo[1]','nvarchar(255)') AS ProjectNo
from @x.nodes('/root/ShopAccount') T(c)
declare @idoc int,@xmlPath nvarchar(200)
exec sp_xml_preparedocument @idoc OUTPUT, @x
set @xmlPath='/root/ShopAccount'
select
ROW_NUMBER() OVER (order by ActivityType) AS ROWID,
ActivityType,
ProjectNo
from OPENXML (@idoc, @xmlPath)
WITH(ActivityType nvarchar(max) 'ActivityType',
ProjectNo NVARCHAR(20) 'ProjectNo')
exec sp_xml_removedocument @idoc
相关文档:
xml中有以下字符不能出现,否则,xml将不能被正确解析:
&><'
如果在xml中出现了非法字符呢必须将其过滤掉!过滤的方法很简单,替换就可以了:
例如在php xml_parser_create 中,就可以这么做:
$parser = xml_parser_create(); //创建一个parser编辑器
xml_set_element_handler($parser, "startElement", " ......
精短高效的XML解析器,纯C单一程序,应用于银行的国税库行横向联网接口系统中,稳定可靠,运行速度飞快,非相应的JAVA程序可比.以下为大部分源码:
/* Copyright (c) 2005 wzs */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <varargs.h>
#i ......
一、XML只有一个Table的情况
(1)userInfo.xml
<?xml version="1.0" encoding="utf-8" ?>
<UserInfo ......
If XML data in the table is less than 32K for each record, then you can directly unload the data as char. If XML data exceeds 32K for some records, then you have to unload the common data and the XML data separately. First, create a template for unloading XML into a PDS: TEMPLATE LOBFRV DSN 'AAA. ......