0

如果我们知道节点名,如何获取 XML 的元素。我有一个如下所示的示例 XML。

<?xml version="1.0"?>
<!DOCTYPE PARTS SYSTEM "parts.dtd">
<?xml-stylesheet type="text/css" href="xmlpartsstyle.css"?>
<PARTS>
   <TITLE>Computer Parts</TITLE>
<PART>
  <ITEM>Motherboard</ITEM>
  <MANUFACTURER>ASUS</MANUFACTURER>
  <MODEL>P3B-F</MODEL>
  <COST> 123.00</COST>
</PART>
<PART>
  <ITEM>Video Card</ITEM>
  <MANUFACTURER>ATI</MANUFACTURER>
  <MODEL>All-in-Wonder Pro</MODEL>
  <COST> 160.00</COST>
</PART>
<PART>
  <ITEM>Sound Card</ITEM>
  <MANUFACTURER>Creative Labs</MANUFACTURER>
  <MODEL>Sound Blaster Live</MODEL>
  <COST> 80.00</COST>
</PART>
<PART>
  <ITEMᡋ inch Monitor</ITEM>
  <MANUFACTURER>LG Electronics</MANUFACTURER>
  <MODEL> 995E</MODEL>
  <COST> 290.00</COST>
</PART>

我想使用 esql 获取数组中的所有元素。怎么做?

4

2 回答 2

0
FOR part AS OutputRoot.XMLNSC.PARTS.PART[] DO
        SET item = part.ITEM;
        SET manufacturer= part.MANUFACTURER;
        SET model= part.MODEL;
        SET cost = part.COST;
        -- do what you want... 
END FOR;
于 2014-10-23T22:41:02.323 回答
0

假设您正在解析条目上的 xml,那么您可以简单地使用以下内容:

SET myvar[] = InputRoot.XMLNSC.PARTS.PART[]
于 2017-06-05T20:08:37.037 回答