XML XQuery
--XQuery 基于现有的 XPath 查询语言,并支持更好的迭代、更好的排序结果以及构造必需的 XML 的功能。
--1.声明一个 xml 类型的变量,然后使用 xml 数据类型的 query() 方法来查询此变量
DECLARE @x xml
SET @x = '<ROOT><a>111</a></ROOT>'
SELECT @x.query('/ROOT/a')
--查找属性aid=20的a节点
DECLARE @x xml
SET @x = '<ROOT>
<a aid="10">10</a>
<a aid="20">20</a>
</ROOT>'
SELECT @x.query('/ROOT/a[@aid=20]')
--2.询是针对 AdventureWorks 数据库中 ProductModel 表的 xml 类型的 Instructions 列指定的。
--查找条件ProductModelID=7,属性LocationID=10的Location节点
SELECT Instructions.query('declare namespace AWMI="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions";
/AWMI:root/AWMI:Location[@LocationID=10]
') as Result
from Production.ProductModel
WHERE ProductModelID=7
--XQuery 包含命名空间声明(declare namespace AWMI=...)和查询表达式(/AWMI:root/AWMI:Location[@LocationID=10])。
DECLARE @x xml
SET @x = '<ROOT>
<a aid="10">10</a>
<a aid="20">20</a>
</ROOT>'
SELECT @x.query('/ROOT/a[@aid=20]')
相关文档:
反射是 Java 语言被视为动态或准动态语言的一个关键性质,结合反射和 XML 会帮助我们更快、更方便地实现一些动态代码,从而解决编程中可能遇到的不确定问题。本文将结合反射与 XML 对 Java 编程的动态性进行深入浅出的讨论。在理解本文的思想之后,您可以将其应用到程序中以创建灵活的代码。
引言
在现实生活中,经常会发 ......
创建XML文件:
public boolean createXML(){
try{
Document doc = DocumentHelper.createDocument();
Element root = doc.addElement("root");
Element personNode = root.addElement("person");
Element sonNode = personNode ......
如何在VC环境下编写程序读取XML文件?清提供源代码.谢谢.
#import <msxml3.dll> named_guids //导入动态库,装了IE5就有
using namespace MSXML2; //引用命名空间,一般可以把命名空间理解成类和接口的集合,呵呵,对不对我也不知道了
#include <vector>
using na ......
/*
* 主要作用;
* 从xml读取游戏配置信息或保存
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Forms;
using System.IO;
using System.Xml;
using System.Reflection;
namespace Game
{
class Config
{
Ke ......