D Bus学习(九):利用XML定义D Bus之Singal收发例子
在前面我们学习了使用Glib的高程捆绑方式的method的收发,现在学习singal的收发,xml例子如下
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/com/wei/MyObject">
<interface name="com.wei.MyObject.Sample">
<method name="Test">
<arg name="x" type="u" direction="in" />
<arg name="d_ret" type="d" direction="out" />
</method >
<signal name="Hello">
<arg name="w_dialog" type="s" />
</signal>
</interface >
</node >
在前面我们已经学习了方法Test的处理,现在增加一个信号Hello,为了是的处理方式更为简洁,这个信号只带来一个叫做w_dialog的字符串。同样我们使用dbus-binding-tool工具分别生成了server的头文件wei_server2.h和client的头文件wei_client2.h。(操作方式,请参阅上两次学习)。
Server的编写
查看wei_server2.h,和之前只有method的相比,只有稍稍的改动,在对象的info中,增加了Hello的说明。如下:
... ...
const DBusGObjectInfo dbus_glib_com_wei_object_info = {
0,
dbus_glib_com_wei_methods,
1,
"com.wei.MyObject.Sample\0Test\0S\0x\0I\0u\0d_ret\0O\0F\0N\0d\0\0\0",
"com.wei.MyObject.Sample\0Hello\0\0"
,
"\0"
};
我们需要对象中增加相关的代码,头文件com_wei_myobject2.h如下:
#ifndef WEI_COM_WEI_MYOBJECT2_H
#define WEI_COM_WEI_MYOBJECT2_H
typedef struct ComWeiMyObject2 ComWeiMyObject2;
typedef struct ComWeiMyObject2Class ComWeiMyObject2Class;
struct ComWeiMyObject2
{
GObject parent;
};
struct ComWeiMyObject2Class
{
GObjectClass parent;
};
#define COM_WEI_MYOBJECT2_TYPE (com_wei_myobject2_get_type())
GType com_wei_myobject2_get_type(void);
gboolean com_wei_test(ComWeiMyObject2 * obj ,
相关文档:
对于带有表空间xmlns的xml文件的解析,用正常解析文件的方法总是失效,不起作用,无法获得元素。
下面给出两种方法解析此类文件:
1.按正常解析xml文件的方法,需要注意几点:
获取元素Element,不可使用函数:document.selectNodes("//region");
只可以先取到根元素,一级一级往下取,eg:
Element root = document.g ......
很多人对Xpath可能比较熟悉,但不知道有没有直接操作过数据库,我们都知道 在Sql2005里公支持的几种查询有Raw,Auto,Path模式等,如果在2000里使用过 Path模式的朋友应该知道,是不容易处理查询结果的,那么在2005里对这一块做了很好的提升
我先来介绍一下什么是Sql F ......
1.要解析的XML文件如下:
<?xml version="1.0" encoding="GB2312"?>
<?xml-stylesheet href="student.xsl" type="text/xsl"?>
<StudentInfo>
<student>
<name>达内</name>
<sex>男</sex>
<lesson>
  ......
一、测试用的em.xml
<?xml version="1.0" encoding="GB2312"?>
<EW cmd="login" mod="Login" version="6.0">
<Source uns="" type="user"/>
<Username>zhangzhiyun@hp</Username>
<Password>111111</Password> ......
Retrieving an XML document using Ajax
http://www.javascriptkit.com/dhtmltutors/ajaxgetpost3.shtml
When making a server request in Ajax, the data returned can be in either
plain text/html, or an XML document instead. The later is technically
just a text file as well, but with s ......