我很想知道,XPath是否能够恢复一系列价值。
我有这样的想法:
<Cities>
<City>Paris</City>
<City>Lyon</City>
<City>Marseille</City>
</Cities>
我也想获得一系列这样的形式[巴黎、里昂、马赛]。
I am using the xpath UNIX utility.
任何想法?
我很想知道,XPath是否能够恢复一系列价值。
我有这样的想法:
<Cities>
<City>Paris</City>
<City>Lyon</City>
<City>Marseille</City>
</Cities>
我也想获得一系列这样的形式[巴黎、里昂、马赛]。
I am using the xpath UNIX utility.
任何想法?
除后处理外,还产出:
xpath -q -e //City/text() inputfile
:
Paris
Lyon
Marseille
(a) 以各种方式,包括:
xpath -q -e //City/text() inputfile |
awk BEGIN {sq = " 47"; OFS = sq "," sq}
{a[$1] = NR}
END {
printf "[" sq;
for (i in a) {
printf "%s%s", d, i; d = OFS};
print sq "]"
}
产出:
[ Lyon , Marseille , Paris ]
您可使用经修改的<代码>xpath。 既然是简单的Perl书,我修改了该书,使你对产出格式有了更大的控制。 有了我的版本,你可以做到:
xpath -q -b "[" -p " " -i "," -s " " -a "]"$
-e //City/text()
获取预期产出。 这里是使用信息:
Usage:
xpath [options] -e query [-e query...] [filename...]
If no filenames are given, supply XML on STDIN.
You must provide at least one query. Each supplementary
query is done in order, the previous query giving the
context of the next one.
Options:
-q quiet Only output the resulting PATH
-b before use before instead of nothing.
-p prefix use prefix instead of nothing.
-s suffix use suffix instead of linefeed.
-i infix use infix instead of nothing.
-a after use after instead of nothing.
页: 1 下载我的版本。
www.un.org/Depts/DGACM/index_spanish.htm The XPath expression:
/*/*/text()
确切地选择了三个希望的案文节点。
www.un.org/Depts/DGACM/index_spanish.htm 您可以使用各种像样的编号:
/*/*/text()[1]
案文选择
"Paris"
,
/*/*/text()[2]
案文选择
"Lyon"
,
/*/*/text()[3]
案文选择
"Marseille"
www.un.org/Depts/DGACM/index_spanish.htm 如果你只想看这些案文的任何节点的可见价值,则使用(例如):
string(/*/*/text()[2])
对这一口号进行评价的结果是说明
"Lyon"
i 知道。 您可在xmlDocument
上查阅;xDoc.SelectNodes("/City”);
中向您提供一份节点清单,每个节点均可填写
I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...
I would like to know the size of the movie I am watching on any video site [ if not possible on all video sites, then at least on YouTube ]. So is it possible, say I will specify the complete path ...
Is it possible to get the property of a class from string and then set a value? Example: string s = "label1.text"; string value = "new value"; label1.text = value; <--and some code that makes ...
I need to parse a xml string to obtain the xml DOM, the problem I m facing is with the self closing html tag like <br /> giving me the error of Tag mismatch expected </br>. I m aware this ...
The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...
I can easily do this with JQuery or PHP but I have a project for my Intro to C++ class and I thought it ll be pretty cool if I could mix C++ with some APIs like twitter, google, yahoo etc. Could you ...
I have never dealt with regular expressions before, and I am facing a problem here. The user has to input a text like Var1(0,enum1,enum2), and I have to check the syntax on the following manner:- 1- ...
I built a site a long time ago and now I want to place the data into a database without copying and pasting the 400+ pages that it has grown to so that I can make the site database driven. My site ...