我知道這是從原來的問題不同,但它是一個思考過程中,我在想達到以下所需的結果:如何建立一個分層的部分/款/款「路徑」
XML輸入:
<section hangIndent="no" indent="arabic 1 digit"
isProposedAmendment="no" label="2A">
<title>AAA</title>
<body>
BBB<subSection label="1">
<body>
<para hangIndent="yes" indent="loweralpha 1 character"
isProposedAmendment="no" label="a">
<body>
CCC
</body>
</para>
<para hangIndent="yes" indent="loweralpha 1 character"
isProposedAmendment="no" label="b">
<body>
DDD
</body>
</para>
<para hangIndent="yes" indent="loweralpha 1 character"
isProposedAmendment="no" label="c">
<body>
EEE
</body>
</para>
</body>
</subSection>
</body>
<annotation isProposedAmendment="no">
FFFFF
</annotation>
</section>
所需的輸出:我建立一個基於每個節點的標籤的xmlpath名稱,並將其插入到每個端點。
<nm:xmlpath name ="2A" />
<section hangIndent="no" indent="arabic 1 digit"
isProposedAmendment="no" label="2A">
<title>AAA</title>
<body>
BBB
<nm:xmlpath name ="2A 1" />
<subSection label="1">
<body>
<nm:xmlpath name ="2A 1(a)" />
<para hangIndent="yes" indent="loweralpha 1 character"
isProposedAmendment="no" label="a">
<body>
CCC
</body>
</para>
<nm:xmlpath name ="2A 1(b)" />
<para hangIndent="yes" indent="loweralpha 1 character"
isProposedAmendment="no" label="b">
<body>
DDD
</body>
</para>
<nm:xmlpath name ="2A 1(c)" />
<para hangIndent="yes" indent="loweralpha 1 character"
isProposedAmendment="no" label="c">
<body>
EEE
</body>
</para>
</body>
</subSection>
</body>
<annotation isProposedAmendment="no">
FFFFF
</annotation>
</section>
但是按照這個速度,**沒有根元素**你的XML可能會變成無效的!你還好嗎? – 2013-03-15 12:02:36
@ InfantPro'Aravind'它將擁有一個根的大型xml的測試數據。謝謝。 – luckyluke 2013-03-15 12:13:37
如果有更多的上下文,請向我們展示轉換的輸入和包含根元素的所需輸出的示例,否則很難推薦代碼。 – 2013-03-15 12:16:34