Accessing XML attributes with namespaces

后端 未结 2 2142
一整个雨季
一整个雨季 2021-02-20 17:23

How one can access attributes with namespaces? My XML data are in a form

val d = 
<
2条回答
  •  野性不改
    2021-02-20 17:49

    The API documentation refers to the following syntax ns \ "@{uri}foo".

    In your example there is no namespace defined, and it seems Scala considers your attribute as unprefixed. See d.attributes.getClass.

    Now if you do this:

    val d = 
    

    Then:

    scala> d \ "@{http://www.w3.org/1999/02/22-rdf-syntax-ns#}about"
    res21: scala.xml.NodeSeq = #item_1
    
    scala> d.attributes.getClass
    res22: java.lang.Class[_] = class scala.xml.PrefixedAttribute
    

提交回复
热议问题