简体   繁体   English

在XML中,您如何称呼它://@Dohicky.0以及如何在Java中解决它

[英]In XML what do you call this: //@Dohicky.0 and how to address it in Java

It's my first time parsing XML and I don't really know what I'm doing at the moment. 这是我第一次解析XML,现在我真的不知道我在做什么。 Here's my XML: 这是我的XML:

<?xml version="1.0" encoding="UTF-8"?>
<MyDocument xmi:version="2.0">
  <Thingamabob name="A" hasDohicky="//@Dohicky.0">
    <Dingus/>
  </Thingamabob>
  <Dohicky name="B"/>
</MyDocument>

So what is "//@Dohicky.0" called? 那么“ //@Dohicky.0”叫什么呢? I understand the purpose, but I'm don't know how to deal with it when I'm parsing XML through Java JAXP. 我理解了目的,但是当我通过Java JAXP解析XML时我不知道如何处理它。 I guess I could parse the hasDohicky attribute's value and then lookfor the 0th occurrence of an element by that name... but I bet there's got to be a better way, right? 我想我可以解析hasDohicky属性的值,然后用该名称查找元素的第0次出现...但是我敢打赌,必须有一种更好的方法,对吗?

Thanks All! 谢谢大家!

In general it's an Attribute (like the "name" attributes in Dohicky and Thingamabob ) 通常,它是一个属性(例如DohickyThingamabob的“ name”属性)

In this case hasDohicky looks a bit like a XQuery string, though I am not sure about the ".0" part see here for more info about XQuery. 在这种情况下, hasDohicky看起来有点像XQuery字符串,尽管我不确定“ .0”部分,有关XQuery的更多信息,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM