-1
私はXML
ファイルをUnixサーバに置いています。 Tcl
スクリプトを使用してそのファイルXML
を実行するにはどうすればよいですか?TCLスクリプトを使用してxmlファイルを実行するにはどうすればよいですか?
私はXML
ファイルをUnixサーバに置いています。 Tcl
スクリプトを使用してそのファイルXML
を実行するにはどうすればよいですか?TCLスクリプトを使用してxmlファイルを実行するにはどうすればよいですか?
XMLを解析するための簡単な方法を探しているなら、tdomパッケージを検討してください。
参考:XMLの含有量が多い場合には、変数(ない最良の方法にXMLデータを読み取る
<my_root>
<my_child1>
<my_subchild1 foo="bar">bat</my_subchild1>
</my_child1>
</my_root>
はここで次の内容のファイルfoo.xmlです):
%
% set fd [open foo.xml]
file3
% set xml [read $fd]
<my_root>
<my_child1>
<my_subchild1 foo="bar">bat</my_subchild1>
</my_child1>
</my_root>
% close $fd
%
今それを解析:
% package require tdom
0.8.3
%
% set documentHandle [dom parse $xml]
domDoc0x2510320
% set root [$documentHandle documentElement]
domNode0x2546d90
% $root asXML
<my_root>
<my_child1>
<my_subchild1 foo="bar">bat</my_subchild1>
</my_child1>
</my_root>
% set child1 [$root firstChild]
domNode0x16dcec0
% $child1 asXML
<my_child1>
<my_subchild1 foo="bar">bat</my_subchild1>
</my_child1>
% set tmp [$root selectNodes //my_subchild1]
domNode0x16dd630
% $tmp asXML
<my_subchild1 foo="bar">bat</my_subchild1>
% $tmp getAttribute foo
bar
% $tmp text
bat
%
ここで解析されたXMLノードでサポートされるコマンドのリストです:
% $tmp
Usage nodeObj <method> <args>, where method can be:
nodeType
nodeName
nodeValue ?newValue?
hasChildNodes
childNodes
childNodesLive
parentNode
firstChild ?nodeObjVar?
lastChild ?nodeObjVar?
nextSibling ?nodeObjVar?
previousSibling ?nodeObjVar?
hasAttribute attrName
getAttribute attrName ?defaultValue?
setAttribute attrName value ?attrName value ...?
removeAttribute attrName
hasAttributeNS uri localName
getAttributeNS uri localName ?defaultValue?
setAttributeNS uri attrName value ?attrName value ...?
removeAttributeNS uri attrName
attributes ?attrNamePattern?
appendChild new
insertBefore new ref
replaceChild new old
removeChild child
cloneNode ?-deep?
ownerDocument
getElementsByTagName name
getElementsByTagNameNS uri localname
getElementById id
find attrName attrValue ?nodeObjVar?
child number|all ?type? ?attrName attrValue?
descendant number|all ?type? ?attrName attrValue?
ancestor number|all ?type? ?attrName attrValue?
fsibling number|all ?type? ?attrName attrValue?
psibling number|all ?type? ?attrName attrValue?
root ?nodeObjVar?
target
data
text
prefix
namespaceURI
getBaseURI
baseURI ?URI?
localName
delete
getLine
getColumn
@<attrName> ?defaultValue?
asList
asXML ?-indent <none,0..8>? ?-channel <channel>? ?-escapeNonASCII? ?-escapeAllQuot? ?-doctypeDeclaration <boolean>?
asHTML ?-channel <channelId>? ?-escapeNonASCII? ?-htmlEntities?
asText
appendFromList nestedList
appendFromScript script
insertBeforeFromScript script ref
appendXML xmlString
selectNodes ?-namespaces prefixUriList? ?-cache <boolean>? xpathQuery ?typeVar?
toXPath
disableOutputEscaping ?boolean?
precedes node
normalize ?-forXPath?
xslt ?-parameters parameterList? <xsltDocNode>
readlock
writelock
%
何を意味する 'xmlファイルを実行して' んが? XMLファイルは、名前の値のペアを持つデータストレージデバイスです。 –
TCLを使用してXML文書を解析しようとしていますか? –
冗長なステートメントを削除することで合理化されました。フォーマットされた技術用語。 – MarsAtomic