http://www.zvon.org/xxl/XPathTutorial/General_chi/examples.html

简介

XPath由W3C的 XPath 1.0 标准描述.本教程通过实例来展示XPath的一些特性.

你可以从以下内容开始:



1。基本的XPath语法类似于在一个文件系统中定位文件,如果路径以斜线 / 开始, 那么该路径就表示到一个元素的绝对路径

/AAA
选择根元素AAA


     <AAA>

          <BBB/>

          <CCC/>

          <BBB/>

          <BBB/>

          <DDD>

               <BBB/>

          </DDD>

          <CCC/>

     </AAA>
/AAA/CCC
选择AAA的所有CCC子元素


     <AAA>

          <BBB/>

          <CCC/>

          <BBB/>

          <BBB/>

          <DDD>

               <BBB/>

          </DDD>

          <CCC/>

     </AAA>
/AAA/DDD/BBB
选择AAA的子元素DDD的所有子元素


     <AAA>

          <BBB/>

          <CCC/>

          <BBB/>

          <BBB/>

          <DDD>

               <BBB/>

          </DDD>

          <CCC/>

     </AAA>

2。如果路径以双斜线 // 开头, 则表示选择文档中所有满足双斜线//之后规则的元素(无论层级关系)

//BBB
选择所有BBB元素


     <AAA>

          <BBB/>

          <CCC/>

          <BBB/>

          <DDD>

               <BBB/>

          </DDD>

          <CCC>

               <DDD>

                    <BBB/>

                    <BBB/>

               </DDD>

          </CCC>

     </AAA>
//DDD/BBB
选择所有父元素是DDD的BBB元素


     <AAA>

          <BBB/>

          <CCC/>

          <BBB/>

          <DDD>

               <BBB/>

          </DDD>

          <CCC>

               <DDD>

                    <BBB/>

                    <BBB/>

               </DDD>

          </CCC>

     </AAA>

3。星号 * 表示选择所有由星号之前的路径所定位的元素

/AAA/CCC/DDD/*
选择所有路径依附于/AAA/CCC/DDD的元素


     <AAA>

          <XXX>

               <DDD>

                    <BBB/>

                    <BBB/>

                    <EEE/>

                    <FFF/>

               </DDD>

          </XXX>

          <CCC>

               <DDD>

                    <BBB/>

                    <BBB/>

                    <EEE/>

                    <FFF/>

               </DDD>

          </CCC>

          <CCC>

               <BBB>

                    <BBB>

                         <BBB/>

                    </BBB>

               </BBB>

          </CCC>

     </AAA>
/*/*/*/BBB
选择所有的有3个祖先元素的BBB元素


     <AAA>

          <XXX>

               <DDD>

                    <BBB/>

                    <BBB/>

                    <EEE/>

                    <FFF/>

               </DDD>

          </XXX>

          <CCC>

               <DDD>

                    <BBB/>

                    <BBB/>

                    <EEE/>

                    <FFF/>

               </DDD>

          </CCC>

          <CCC>

               <BBB>

                    <BBB>

                         <BBB/>

                    </BBB>

               </BBB>

          </CCC>

     </AAA>
//*
选择所有元素


     <AAA>

          <XXX>

               <DDD>

                    <BBB/>

                    <BBB/>

                    <EEE/>

                    <FFF/>

               </DDD>

          </XXX>

          <CCC>

               <DDD>

                    <BBB/>

                    <BBB/>

                    <EEE/>

                    <FFF/>

               </DDD>

          </CCC>

          <CCC>

               <BBB>

                    <BBB>

                         <BBB/>

                    </BBB>

               </BBB>

          </CCC>

     </AAA>

4。方块号里的表达式可以进一步的指定元素, 其中数字表示元素在选择集里的位置, 而last()函数则表示选择集中的最后一个元素.

/AAA/BBB[1]
选择AAA的第一个BBB子元素


     <AAA>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

     </AAA>
/AAA/BBB[last()]
选择AAA的最后一个BBB子元素


     <AAA>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

     </AAA>

5。

//@id
选择所有的id属性


     <AAA>

          <BBB id = "b1"/>

          <BBB id = "b2"/>

          <BBB name = "bbb"/>

          <BBB/>

     </AAA>
//BBB[@id]
选择有id属性的BBB元素


     <AAA>

          <BBB id = "b1"/>

          <BBB id = "b2"/>

          <BBB name = "bbb"/>

          <BBB/>

     </AAA>
//BBB[@name]
选择有name属性的BBB元素


     <AAA>

          <BBB id = "b1"/>

          <BBB id = "b2"/>

          <BBB name = "bbb"/>

          <BBB/>

     </AAA>
//BBB[@*]
选择有任意属性的BBB元素


     <AAA>

          <BBB id = "b1"/>

          <BBB id = "b2"/>

          <BBB name = "bbb"/>

          <BBB/>

     </AAA>
//BBB[not(@*)]
选择没有属性的BBB元素


     <AAA>

          <BBB id = "b1"/>

          <BBB id = "b2"/>

          <BBB name = "bbb"/>

          <BBB/>

     </AAA>

6。属性的值可以被用来作为选择的准则, normalize-space函数删除了前部和尾部的空格, 并且把连续的空格串替换为一个单一的空格

//BBB[@id='b1']
选择含有属性id且其值为'b1'的BBB元素


     <AAA>

          <BBB id = "b1"/>

          <BBB name = " bbb "/>

          <BBB name = "bbb"/>

     </AAA>
//BBB[@name='bbb']
选择含有属性name且其值为'bbb'的BBB元素


     <AAA>

          <BBB id = "b1"/>

          <BBB name = " bbb "/>

          <BBB name = "bbb"/>

     </AAA>
//BBB[normalize-space(@name)='bbb']
选择含有属性name且其值(在用normalize-space函数去掉前后空格后)为'bbb'的BBB元素


     <AAA>

          <BBB id = "b1"/>

          <BBB name = " bbb "/>

          <BBB name = "bbb"/>

     </AAA>

7。count()函数可以计数所选元素的个数

//*[count(BBB)=2]
选择含有2个BBB子元素的元素


     <AAA>

          <CCC>

               <BBB/>

               <BBB/>

               <BBB/>

          </CCC>

          <DDD>

               <BBB/>

               <BBB/>

          </DDD>

          <EEE>

               <CCC/>

               <DDD/>

          </EEE>

     </AAA>
//*[count(*)=2]
选择含有2个子元素的元素


     <AAA>

          <CCC>

               <BBB/>

               <BBB/>

               <BBB/>

          </CCC>

          <DDD>

               <BBB/>

               <BBB/>

          </DDD>

          <EEE>

               <CCC/>

               <DDD/>

          </EEE>

     </AAA>
//*[count(*)=3]
选择含有3个子元素的元素


     <AAA>

          <CCC>

               <BBB/>

               <BBB/>

               <BBB/>

          </CCC>

          <DDD>

               <BBB/>

               <BBB/>

          </DDD>

          <EEE>

               <CCC/>

               <DDD/>

          </EEE>

     </AAA>

8。name()函数返回元素的名称, start-with()函数在该函数的第一个参数字符串是以第二个参数字符开始的情况返回true, contains()函数当其第一个字符串参数包含有第二个字符串参数时返回true.

//*[name()='BBB']
选择所有名称为BBB的元素(这里等价于//BBB)


     <AAA>

          <BCC>

               <BBB/>

               <BBB/>

               <BBB/>

          </BCC>

          <DDB>

               <BBB/>

               <BBB/>

          </DDB>

          <BEC>

               <CCC/>

               <DBD/>

          </BEC>

     </AAA>
//*[starts-with(name(),'B')]
选择所有名称以"B"起始的元素


     <AAA>

          <BCC>

               <BBB/>

               <BBB/>

               <BBB/>

          </BCC>

          <DDB>

               <BBB/>

               <BBB/>

          </DDB>

          <BEC>

               <CCC/>

               <DBD/>

          </BEC>

     </AAA>
//*[contains(name(),'C')]
选择所有名称包含"C"的元素


     <AAA>

          <BCC>

               <BBB/>

               <BBB/>

               <BBB/>

          </BCC>

          <DDB>

               <BBB/>

               <BBB/>

          </DDB>

          <BEC>

               <CCC/>

               <DBD/>

          </BEC>

     </AAA>

9。string-length函数返回字符串的字符数,你应该用&lt;替代<, 用&gt;代替>

//*[string-length(name()) = 3]
选择名字长度为3的元素


     <AAA>

          <Q/>

          <SSSS/>

          <BB/>

          <CCC/>

          <DDDDDDDD/>

          <EEEE/>

     </AAA>
//*[string-length(name()) < 3]
选择名字长度小于3的元素


     <AAA>

          <Q/>

          <SSSS/>

          <BB/>

          <CCC/>

          <DDDDDDDD/>

          <EEEE/>

     </AAA>
//*[string-length(name()) > 3]
选择名字长度大于3的元素


     <AAA>

          <Q/>

          <SSSS/>

          <BB/>

          <CCC/>

          <DDDDDDDD/>

          <EEEE/>

     </AAA>

10。多个路径可以用分隔符 | 合并在一起

//CCC | //BBB
选择所有的CCC和BBB元素


     <AAA>

          <BBB/>

          <CCC/>

          <DDD>

               <CCC/>

          </DDD>

          <EEE/>

     </AAA>
/AAA/EEE | //BBB
选择所有的BBB元素和所有是AAA的子元素的EEE元素


     <AAA>

          <BBB/>

          <CCC/>

          <DDD>

               <CCC/>

          </DDD>

          <EEE/>

     </AAA>
/AAA/EEE | //DDD/CCC | /AAA | //BBB
可以合并的路径数目没有限制


     <AAA>

          <BBB/>

          <CCC/>

          <DDD>

               <CCC/>

          </DDD>

          <EEE/>

     </AAA>

11。child轴(axis)包含上下文节点的子元素, 作为默认的轴,可以忽略不写.

/AAA
等价于 /child::AAA


     <AAA>

          <BBB/>

          <CCC/>

     </AAA>
/child::AAA
等价于/AAA


     <AAA>

          <BBB/>

          <CCC/>

     </AAA>
/AAA/BBB
等价于/child::AAA/child::BBB


     <AAA>

          <BBB/>

          <CCC/>

     </AAA>
/child::AAA/child::BBB
等价于/AAA/BBB


     <AAA>

          <BBB/>

          <CCC/>

     </AAA>
/child::AAA/BBB
二者都可以被合并


     <AAA>

          <BBB/>

          <CCC/>

     </AAA>

12。descendant (后代)轴包含上下文节点的后代,一个后代是指子节点或者子节点的子节点等等, 因此descendant轴不会包含属性和命名空间节点.

/descendant::*
选择文档根元素的所有后代.即所有的元素被选择


     <AAA>

          <BBB>

               <DDD>

                    <CCC>

                         <DDD/>

                         <EEE/>

                    </CCC>

               </DDD>

          </BBB>

          <CCC>

               <DDD>

                    <EEE>

                         <DDD>

                              <FFF/>

                         </DDD>

                    </EEE>

               </DDD>

          </CCC>

     </AAA>
/AAA/BBB/descendant::*
选择/AAA/BBB的所有后代元素


     <AAA>

          <BBB>

               <DDD>

                    <CCC>

                         <DDD/>

                         <EEE/>

                    </CCC>

               </DDD>

          </BBB>

          <CCC>

               <DDD>

                    <EEE>

                         <DDD>

                              <FFF/>

                         </DDD>

                    </EEE>

               </DDD>

          </CCC>

     </AAA>
//CCC/descendant::*
选择在祖先元素中有CCC的所有元素


     <AAA>

          <BBB>

               <DDD>

                    <CCC>

                         <DDD/>

                         <EEE/>

                    </CCC>

               </DDD>

          </BBB>

          <CCC>

               <DDD>

                    <EEE>

                         <DDD>

                              <FFF/>

                         </DDD>

                    </EEE>

               </DDD>

          </CCC>

     </AAA>
//CCC/descendant::DDD
选择所有以CCC为祖先元素的DDD元素


     <AAA>

          <BBB>

               <DDD>

                    <CCC>

                         <DDD/>

                         <EEE/>

                    </CCC>

               </DDD>

          </BBB>

          <CCC>

               <DDD>

                    <EEE>

                         <DDD>

                              <FFF/>

                         </DDD>

                    </EEE>

               </DDD>

          </CCC>

     </AAA>

13。parent轴(axis)包含上下文节点的父节点, 如果有父节点的话

//DDD/parent::*
选择DDD元素的所有父节点


     <AAA>

          <BBB>

               <DDD>

                    <CCC>

                         <DDD/>

                         <EEE/>

                    </CCC>

               </DDD>

          </BBB>

          <CCC>

               <DDD>

                    <EEE>

                         <DDD>

                              <FFF/>

                         </DDD>

                    </EEE>

               </DDD>

          </CCC>

     </AAA>

14。ancestor轴(axis)包含上下节点的祖先节点, 该祖先节点由其上下文节点的父节点以及父节点的父节点等等诸如此类的节点构成,所以ancestor轴总是包含有根节点,除非上下文节点就是根节点本身.

/AAA/BBB/DDD/CCC/EEE/ancestor::*
选择一个绝对路径上的所有节点


     <AAA>

          <BBB>

               <DDD>

                    <CCC>

                         <DDD/>

                         <EEE/>

                    </CCC>

               </DDD>

          </BBB>

          <CCC>

               <DDD>

                    <EEE>

                         <DDD>

                              <FFF/>

                         </DDD>

                    </EEE>

               </DDD>

          </CCC>

     </AAA>
//FFF/ancestor::*
选择FFF元素的祖先节点


     <AAA>

          <BBB>

               <DDD>

                    <CCC>

                         <DDD/>

                         <EEE/>

                    </CCC>

               </DDD>

          </BBB>

          <CCC>

               <DDD>

                    <EEE>

                         <DDD>

                              <FFF/>

                         </DDD>

                    </EEE>

               </DDD>

          </CCC>

     </AAA>

15。following-sibling轴(axis)包含上下文节点之后的所有兄弟节点

/AAA/BBB/following-sibling::*


     <AAA>

          <BBB>

               <CCC/>

               <DDD/>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <DDD/>

                    <CCC/>

                    <FFF/>

                    <FFF>

                         <GGG/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>
//CCC/following-sibling::*


     <AAA>

          <BBB>

               <CCC/>

               <DDD/>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <DDD/>

                    <CCC/>

                    <FFF/>

                    <FFF>

                         <GGG/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>

16。preceding-sibling 轴(axis)包含上下文节点之前的所有兄弟节点

/AAA/XXX/preceding-sibling::*


     <AAA>

          <BBB>

               <CCC/>

               <DDD/>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <DDD/>

                    <CCC/>

                    <FFF/>

                    <FFF>

                         <GGG/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>
//CCC/preceding-sibling::*


     <AAA>

          <BBB>

               <CCC/>

               <DDD/>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <DDD/>

                    <CCC/>

                    <FFF/>

                    <FFF>

                         <GGG/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>

17。following轴(axis)包含同一文档中按文档顺序位于上下文节点之后的所有节点, 除了祖先节点,属性节点和命名空间节点

/AAA/XXX/following::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ>

                    <DDD/>

                    <DDD>

                         <EEE/>

                    </DDD>

               </ZZZ>

               <FFF>

                    <GGG/>

               </FFF>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <DDD/>

                    <CCC/>

                    <FFF/>

                    <FFF>

                         <GGG/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>
//ZZZ/following::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ>

                    <DDD/>

                    <DDD>

                         <EEE/>

                    </DDD>

               </ZZZ>

               <FFF>

                    <GGG/>

               </FFF>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <DDD/>

                    <CCC/>

                    <FFF/>

                    <FFF>

                         <GGG/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>

18。following轴(axis)包含同一文档中按文档顺序位于上下文节点之前的所有节点, 除了祖先节点,属性节点和命名空间节点

/AAA/XXX/preceding::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ>

                    <DDD/>

               </ZZZ>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <DDD/>

                    <CCC/>

                    <FFF/>

                    <FFF>

                         <GGG/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>
//GGG/preceding::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ>

                    <DDD/>

               </ZZZ>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <DDD/>

                    <CCC/>

                    <FFF/>

                    <FFF>

                         <GGG/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>

19。descendant-or-self 轴(axis)包含上下文节点本身和该节点的后代节点

/AAA/XXX/descendant-or-self::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ>

                    <DDD/>

               </ZZZ>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <DDD/>

                    <CCC/>

                    <FFF/>

                    <FFF>

                         <GGG/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>
//CCC/descendant-or-self::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ>

                    <DDD/>

               </ZZZ>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <DDD/>

                    <CCC/>

                    <FFF/>

                    <FFF>

                         <GGG/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>

20。ancestor-or-self 轴(axis)包含上下文节点本身和该节点的祖先节点

/AAA/XXX/DDD/EEE/ancestor-or-self::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ>

                    <DDD/>

               </ZZZ>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <DDD/>

                    <CCC/>

                    <FFF/>

                    <FFF>

                         <GGG/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>
//GGG/ancestor-or-self::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ>

                    <DDD/>

               </ZZZ>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <DDD/>

                    <CCC/>

                    <FFF/>

                    <FFF>

                         <GGG/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>

21。ancestor, descendant, following, preceding 和self轴(axis)分割了XML文档(忽略属性节点和命名空间节点), 不能交迭, 而一起使用则包含所有节点

//GGG/ancestor::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ/>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <FFF>

                         <HHH/>

                         <GGG>

                              <JJJ>

                                   <QQQ/>

                              </JJJ>

                              <JJJ/>

                         </GGG>

                         <HHH/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>
//GGG/descendant::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ/>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <FFF>

                         <HHH/>

                         <GGG>

                              <JJJ>

                                   <QQQ/>

                              </JJJ>

                              <JJJ/>

                         </GGG>

                         <HHH/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>
//GGG/following::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ/>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <FFF>

                         <HHH/>

                         <GGG>

                              <JJJ>

                                   <QQQ/>

                              </JJJ>

                              <JJJ/>

                         </GGG>

                         <HHH/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>
//GGG/preceding::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ/>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <FFF>

                         <HHH/>

                         <GGG>

                              <JJJ>

                                   <QQQ/>

                              </JJJ>

                              <JJJ/>

                         </GGG>

                         <HHH/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>
//GGG/self::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ/>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <FFF>

                         <HHH/>

                         <GGG>

                              <JJJ>

                                   <QQQ/>

                              </JJJ>

                              <JJJ/>

                         </GGG>

                         <HHH/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>
//GGG/ancestor::* | //GGG/descendant::* | //GGG/following::* | //GGG/preceding::* | //GGG/self::*


     <AAA>

          <BBB>

               <CCC/>

               <ZZZ/>

          </BBB>

          <XXX>

               <DDD>

                    <EEE/>

                    <FFF>

                         <HHH/>

                         <GGG>

                              <JJJ>

                                   <QQQ/>

                              </JJJ>

                              <JJJ/>

                         </GGG>

                         <HHH/>

                    </FFF>

               </DDD>

          </XXX>

          <CCC>

               <DDD/>

          </CCC>

     </AAA>

22。div运算符做浮点除法运算, mod运算符做求余运算, floor函数返回不大于参数的最大整数(趋近于正无穷), ceiling返回不小于参数的最小整数(趋近于负无穷)

//BBB[position() mod 2 = 0 ]
选择偶数位置的BBB元素


     <AAA>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <CCC/>

          <CCC/>

          <CCC/>

     </AAA>
//BBB[ position() = floor(last() div 2 + 0.5) or position() = ceiling(last() div 2 + 0.5) ]
选择中间的BBB元素


     <AAA>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <CCC/>

          <CCC/>

          <CCC/>

     </AAA>
//CCC[ position() = floor(last() div 2 + 0.5) or position() = ceiling(last() div 2 + 0.5) ]
选择中间的CCC元素


     <AAA>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <BBB/>

          <CCC/>

          <CCC/>

          <CCC/>

     </AAA>

XPath 文档 解析XMl的更多相关文章

  1. xml文档解析

    XML文档解主要分为四种解析方式,官方提供的两种分别是:DOM 和 SAX,第三方分别是:JDOM 和 DOM4j 测试用的xml文档: <?xml version="1.0" ...

  2. Android XML文档解析(一)——SAX解析

    ---------------------------------------------------------------------------------------------------- ...

  3. jsoup -- xml文档解析

    jsoup -- xml文档解析 修改 https://jsoup.org/cookbook/modifying-data/set-attributes https://jsoup.org/cookb ...

  4. iOS网络编程笔记——XML文档解析

    今天利用多余时间研究了一下XML文档解析,虽然现在移动端使用的数据格式基本为JSON格式,但是XML格式毕竟多年来一直在各种计算机语言之间使用,是一种老牌的经典的灵活的数据交换格式.所以我认为还是很有 ...

  5. 【JAVA使用XPath、DOM4J解析XML文件,实现对XML文件的CRUD操作】

    一.简介 1.使用XPath可以快速精确定位指定的节点,以实现对XML文件的CRUD操作. 2.去网上下载一个“XPath帮助文档”,以便于查看语法等详细信息,最好是那种有很多实例的那种. 3.学习X ...

  6. xpath与nodejs解析xml

    测试xpath的工具 http://www.freeformatter.com/xpath-tester.html#ad-output http://www.xpathtester.com/test ...

  7. ios-XML文档解析之SAX解析

    首先SAX解析xml *xml文档的格式特点是节点,大体思路是把每个最小的子节点作为对象的属性,每个最小子节点的'父'节点作为对象,将节点转化为对象,输出. 每个节点都是成对存在的,有开始有结束.有始 ...

  8. (二)发布第一个WebService服务与DSWL文档解析

    1. 编写接口 package service; import javax.jws.WebService; /** * 第一个webservice服务, * @WebService注解表示这是一个we ...

  9. JavaScript : DOM文档解析详解

    JavaScript DOM  文档解析 1.节点(node):来源于网络理论,代表网络中的一个连接点.网络是由节点构成的集合 <p title=“a gentle reminder”> ...

随机推荐

  1. 【BZOJ4066】简单题 KDtree

    [BZOJ4066]简单题 Description 你有一个N*N的棋盘,每个格子内有一个整数,初始时的时候全部为0,现在需要维护两种操作: 命令 参数限制 内容 1 x y A 1<=x,y& ...

  2. 学习 SSH

    ssh_config 与 sshd_config ssh_config: configuration file for the ssh client on the host machine you a ...

  3. 发挥inline-block作用

    .pay-type { // 同行 display: inline-flex; padding: 0 @pay-type_2imgs_padding-width; } .pay-type_icon { ...

  4. Vue中获取dom元素

    Vue.js虽然说是数据驱动页面的,但是有时候我们也要获取dom对象进行一些操作. vue的不同版本获取dom对象的方法不一样 Vue.js  1.0版本中,通过v-el绑定,然后通过this.els ...

  5. matlab学习笔记之基础知识(一)

    一.两种特殊数据类型 1.元胞数组   元胞数组是MATLAB的一种特殊数据类型,可以将元胞数组看做一种无所不包的通用矩阵,或者叫做广义矩阵.组成元胞数组的元素可以是任何一种数据类型的常数或者常量,每 ...

  6. Linux下简单的多线程编程--线程池的实现

    /* 写在前面的话: 今天刚“开原”,选择了一篇关于线程池的文件与大家分享,希望能对您学习有所帮助,也希望能与大家共同学习! 选择在这个特殊的时候注册并发文章也是有一些我个人特殊的意义的,看我的id( ...

  7. spring 编译时抱错纪录class path resource [spring/] cannot be resolved to URL because it does not exist

    class path resource [spring/] cannot be resolved to URL because it does not exist; 在 pom.xml 里添加如下代码 ...

  8. CentOS Linux中zip压缩和unzip解压缩命令详解

    以下命令均在/home目录下操作cd /home  #进入/home目录1.把/home目录下面的mydata目录压缩为mydata.zip     zip -r  mydata.zip   myda ...

  9. gearman background后台job状态获取

    GearmanClient background job有一个方法叫: public array GearmanClient::jobStatus ( string $job_handle ) Get ...

  10. Hibernate学习---检索优化

    Hibernate框架对检索进行了优化,前面我们将CURD的时候提到了load和get的区别,当时仅仅说了load为延迟加载,get为立即加载,当检索的记录为空的时候load报错(不是在执行load方 ...