elementui tree load tree为什么不能选择

tree_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
&&二叉树的基本操作及哈夫曼编码译码系统的实现
阅读已结束,下载文档到电脑
想免费下载更多文档?
定制HR最喜欢的简历
下载文档到电脑,方便使用
还剩10页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢Lua Element Tree
Lua Element Tree
Lua Element Tree is a library that enables manipulation of XML documents
as simple data structures in Lua. The xml document
&root&text1&elt id="1" name="inner"&text2&/elt&&/root&
corresponds for example to the Lua table
tag = "elt",
attr = {"id", "name", id = "1", name = "inner"}
tag = "root",
Two functions provides the main Lua Element Tree functionality:
elt = fromstring(xml) converts an xml string to a table
xml = tostring(elt) converts a table to an xml string
Getting Started - Project Information
The current version of Lua Element Tree is 0.1.
Lua Element Tree can be downloaded from the
Dependencies
Lua Element Tree depends on:
If you want to regenerate the html documentation - with make doc - you also
Installation
Download the etree-0.1 source distribution. Then, as root, type:
shell$ tar zxvf etree-0.1.tar.gz
shell$ cd etree-0.1
shell$ make install
Lua Element Tree is distributed under the .
The Object Model
Lua Element Tree is an extension of
and shares its . XML elements are described by tables that have:
a field tag that holds the element's name,
an optional field attr that stores the element's attributes,
an array-part that stores the element's children.
This model can be considered as a simplification of the
that ignores comments, processing instructions and namespaces.
Because of the lack of such nodes, there is no need to distinguish the root
node from the top-level element. Text nodes are represented as Lua strings,
with an implicit utf-8 encoding. Element attributes are described as a
table whose keys are attribute names and values are attributes values.
The array part of the table may be used to describe the order of the
attributes.
The function fromstring always export elements whose attribute tables are
fully ordered.
elt = etree.fromstring("&elt a='1' b='2' c='3'/&")
elt.attr =& {"a", "b", "c", a="1", b="2", c="3"}
On the other hand, functions that require elements for arguments are more
flexible. They rely on a slight extension of the object model that allows:
a partial ordering of the attribute tables,
the use of any numeric value as an index.
Unordered attributes always appear after the ordered ones in the xml document.
As a consequence, ordered attributes do not need to have consecutives indices:
elt.attr[2] = nil
elt.attr =& {"a", [2]="c", a="1", b="2", c="3"}
etree.tostring(elt) =& "&elt a="1" c="3" b="2"/&"
The use of non-positive or non-integer indices may simplify attribute
reordering:
elt.attr[2] = elt.attr[0] = "c"; elt.attr[0.5] = "b"
elt.attr =& {"a", [0]="c", [0.5]="b", a="1", b="2", c="3"}
etree.tostring(elt) =& "&elt c="3" b="2" a="1"/&"
Unordered attributes appear in no particular order:
elt.attr = {}
etree.tostring(elt) =& "&elt a='1' b='2' c='3'/&"
XML Output Stream
An XML document based on a element may be generated as a string with the
tostring function. This function is a simple helper function whose
implementation is very simple:
function tostring(elt)
buffer = StringBuffer()
ElementTree(elt):write(buffer)
return base.tostring(buffer)
The StringBuffer instance is an example of file-like object: a table that
implements the write method. The arguments to successive calls to write are
stored in order and concatenated when tostring is called.
The ElementTree class is designed such that any such file-like object is an
admissible argument to the write method.
et = ElementTree(elt)
et:write(file)
In particular, io.stdout is a valid choice. This is the default value
when no file argument is given.
XML Output Configuration
The XML output may be configured by an extra options table:
et = ElementTree(elt, options)
The valid options -- decl, empty, attr_sort and encoding -- are
detailled below. For example, to output XML consistent with James Clark's
standard, select
options = {
empty_tags = false,
= etree.lexicographic,
= etree.encoding.most
XML Declaration -- decl
Control the inclusion of an XML declaration in the generated XML document.
Set to true (the default) or false.
Empty Tags -- empty_tags
Allows or forbids the use of the empty tags specific notation.
Set to true (the default) or false.
Attribute Order -- attr_sort
Selects the ordering of attributes in the final document.
The attr_sort value is a function that receives attribute tables as described
in the Object Model section. Such attributes are unordered, partially ordered
or fully ordered. In any case, the function shall produce an array that fully
orders the attribute names.
For example, the function lexicographic ignores any ordering information
that may be given in the attributes table and sort the attributes with the
lexicographic order of their names:
function lexicographic(attrs)
local attrs_ = {}
for attr, _ in attrs do
if type(attr) == "string" then
table.insert(attrs_, attr)
return table.sort(attrs_)
Entity Encoding -- encoding
Provide the encoding maps used to encode the special characters that are
special to XML. The encoding argument shall be a pair of arrays
encoding = {cdata_encoding, attributes_encoding}
The left-hand side strings in these arrays are replaced in order with the
the right-hand side values when the XML is generated. The first array is used
to encode character data and attribute names, the second for attribute values.
The default encoding maps are:
encoding = {
{ {'&',"&"}, {'&',"&}, {'&',"&"} },
{ {'&',"&"}, {'&',"&}, {'&',"&"}, {'"',"&"} }
Element Tree provides four encoding maps via
etree.encoding[i] -- i=1,...,4
The map etree.encoding[1], or etree.encoding["minimal"] only transforms
'&' and '&', adding '"' for the attribute values. The standard map
etree.encoding[1], or etree.encoding. standard adds the symbol '&'.
The map 'etree.encoding[3]', or etree.encoding.strict encodes more symbols
in order to bypass the
XML mecanisms. Finally, the fourth level (most) encodes
all special symbols as well as '\r', '\n' and '\t'.Posts - 24,
Articles - 1,
Comments - 0
15:33 by alapha, ... 阅读,
ElementTree.fromstring()& 导入xml格式时,是可以选择解析parser的编码的,并且 它解析出来的node类型是 严谨且严格的,不会
自己内部全部转换成str,比如 9.87 会解析成float,而不是str字符串9.87,包含有汉字的&Name&李伟&/Name&& 这样的格式,解析出的“李伟 ”& 是python的unicode类型,不会设置字符串的编码格式。!!!重点
另外使用ElementTree.tostring() 到处xml字符串格式时,可以指定字符串格式,以及导出成xml还是text类型
ElementTree.tostring(tree, ‘utf-8’, ‘xml’ )
1.& 凡是涉及到python 中文的,都以unicode来表示,只有当将字符写入文件,写DB 或者网络传输时,才涉及到将 unicode类型 设置UTF-8 或者ASCII或者GBK 等的编码
2.& 当涉及到 中文字符串长度计算的时候:
&&&&& 1.& 可以将 unicode 中文-------&转换成 utf-8,判断 字符值 是不是在& u'\u4e00'&&& 和 u'\u9fa5' ,在这之间的都是汉字
&&&&& 2 . 或者 将unicode 中文-------&转换成 GBK 编码, 每个汉字2字节偏移,来截断或者偏移
3. 编码之后(utf-8& 或者GBK)的汉字是有编码属性的,需要反向 decode成 unicode类型,至于怎么保存在字段或者DB中,需要再次decode(),一般是decoe(‘utf-8’)2014年8月 其他开发语言大版内专家分月排行榜第二2014年7月 其他开发语言大版内专家分月排行榜第二2014年5月 其他开发语言大版内专家分月排行榜第二2014年4月 其他开发语言大版内专家分月排行榜第二2014年3月 其他开发语言大版内专家分月排行榜第二2014年1月 其他开发语言大版内专家分月排行榜第二2013年12月 其他开发语言大版内专家分月排行榜第二2013年11月 其他开发语言大版内专家分月排行榜第二2013年3月 其他开发语言大版内专家分月排行榜第二2012年5月 其他开发语言大版内专家分月排行榜第二2012年4月 其他开发语言大版内专家分月排行榜第二2010年10月 其他开发语言大版内专家分月排行榜第二2010年9月 其他开发语言大版内专家分月排行榜第二
2013年9月 其他开发语言大版内专家分月排行榜第三2012年6月 其他开发语言大版内专家分月排行榜第三
本帖子已过去太久远了,不再提供回复功能。}

我要回帖

更多关于 elementui tree 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信