使用PBDOM读取XML的一个例子
来源:互联网 发布:域名所有者信息怎么填 编辑:程序博客网 时间:2024/05/16 09:12
1、创建pbdom_doc_1.xml,内容如下:
<!DOCTYPE abc [<!ENTITY text "Some Text" >]>
<abc>
<data>
<child_data>Child Data Text</child_data>
<child_data An_Attribute="Some Attribute Value"/>
&text;
<!--Comment String-->
<![CDATA[Some CDATA String]]>
</data>
</abc>
2、将PBDOM90.PBD添加进来(因为编译器的版本为pb9)
读取代码如下:
PBDOM_BUILDER pbdom_bldr
PBDOM_Document pbdom_doc
PBDOM_Object pbdom_obj_array[]
PBDOM_Element pbdom_elem
integer iFileNum1
long l = 0
Try
// Create a PBDOM_DOCUMENT from the XML file
pbdom_bldr = Create PBDOM_Builder
pbdom_doc = pbdom_bldr.BuildFromFile ("pbdom_doc_1.xml")
// Test the contents of the PBDOM_DOCUMENT
// First test the PBDOM_DOCTYPE in the document
MessageBox ("PBDOM_DOCTYPE GetName()", pbdom_doc.GetDocType().GetName())
MessageBox ("PBDOM_DOCTYPE GetInternalSubset()", pbdom_doc.GetDocType().GetInternalSubset())
// Test the root element
MessageBox ("PBDOM_DOC Root Element Name", pbdom_doc.GetRootElement().GetName())
// test the root element's child element
MessageBox ("PBDOM_DOC <data> Element Name", pbdom_doc.GetRootElement().GetChildElement("data").GetName())
// Collect all the child PBDOM_OBJECTs of the
// <data> element
pbdom_doc.GetRootElement().GetChildElement("data").GetContent(pbdom_obj_array)
// Display the class name, the name and the text contained
// within each PBDOM_OBJECT array item
for l = 1 to UpperBound(pbdom_obj_array)
MessageBox ("Child Object " + string(l) + " Class",pbdom_obj_array[l].GetObjectClassString())
MessageBox ("Child Object " + string(l) + " Name", pbdom_obj_array[l].GetName())
MessageBox ("Child Object " + string(l) + " Text",pbdom_obj_array[l].GetText())
next
// Retrieve and display the name and text value of the
// "An_Attribute" attribute from the <child_data> element
pbdom_elem = pbdom_obj_array[2]
MessageBox ("child_data Attribute name", pbdom_elem.GetAttribute("An_Attribute").GetName())
MessageBox ("child_data Attribute value", pbdom_elem.GetAttribute("An_Attribute").GetText())
// save the DOM Tree contained within pbdom_doc into
// a separate file "c:/pbdom_doc_2.xml"
pbdom_doc.SaveDocument ("pbdom_doc_2.xml")
Destroy pbdom_bldr
CATCH (PBDOM_Exception except)
MessageBox ("Exception Occurred", except.Text)
END TRY
- 使用PBDOM读取XML的一个例子
- 使用PBDOM读取XML的一个例子
- 使用PBDOM读取XML的一个例子
- 使用PBDOM解析xml
- 一个使用QtXmlPatterns模块读取xml 的例子
- 一个xmlhttp读取xml的例子
- 一个as3读取xml的例子
- 一个读取和配置XML文件的例子
- xerces C/C++ 读取XML文件的一个小例子
- 使用DOM4J解析XML的一个例子
- mxml 读取 xml 的例子
- java使用dom4j读取xml的简单例子
- java使用dom4j读取xml的简单例子
- PBDOM 解析和生成XML
- 使用JSP + JAVABEAN + XML 开发的一个例子
- 使用JSP + JAVABEAN + XML 开发的一个例子
- 使用JSP + JAVABEAN + XML 开发的一个例子
- 使用JSP + JAVABEAN + XML 开发的一个例子
- Delphi2007使用心得
- MSN无法登录的解决方法
- 将 d2007 的项目移回 d7 中的方法
- 人生中第一次面试!
- 如何理解c和c++的复杂类型声明
- 使用PBDOM读取XML的一个例子
- JSP 身份证验证代码
- DATAGRIDVIEW控制
- 什么是PLC
- 海底捞火锅-一个值得学习的饭店-zt自xfcous blog
- hacker is everywhere 之专利分析-1-zt
- 可怕的无知
- VBA 范例教程(01):VBA 可以做什么?(年历产生器)
- 粗心惹的祸