- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想用 SAXParser 解析 XAPI xml。但现在我遇到了问题。
首先是一段 xml:
<node id="24924135" lat="49.8800274" lon="8.6453740" version="12" timestamp="2012-05-25T15:13:47Z" changeset="11699394" uid="61927" user="AlexPleiner">
<tag k="addr:city" v="Darmstadt"/>
<tag k="addr:housenumber" v="41"/>
<tag k="addr:postcode" v="64293"/>
<tag k="addr:street" v="Kahlertstraße"/>
<tag k="amenity" v="pub"/>
<tag k="name" v="Kneipe 41"/>
<tag k="note" v="DaLUG Meeting (4st Friday of month 19:30)"/>
<tag k="smoking" v="no"/>
<tag k="website" v="http://www.kneipe41.de/"/>
<tag k="wheelchair" v="limited"/>
还有一段我的 SAXParser 代码:
public void startElement(String uri, String localName, String qName,
Attributes atts) throws SAXException {
if (localName.equals("node")) {
// Neue Person erzeugen
poi = new POIS();
poi.setLat(Float.parseFloat(atts.getValue("lat")));
poi.setLon(Float.parseFloat(atts.getValue("lon")));
}
}
public void endElement(String uri, String localName, String qName) throws SAXException {
poi.setHouseNo(currentValue);
if (localName.equals("addr:street")) {
poi.setStreet(currentValue);
}
if (localName.equals("amenity")) {
poi.setType(currentValue);
}
}
纬度和经度不是问题,而是标签“标签”。
如何检查“k”并获取 v 的值?
有人知道吗? :)
最佳答案
您感兴趣的值是 xml 属性,将在 startElement(...)
方法中由传入的 Attributes
参数表示。
您需要做的与您为 node
元素所做的非常相似。
public void startElement(String uri, String localName, String qName,
Attributes atts) throws SAXException
{
//your other node code
if(localname.equals("tag")) {
String k = atts.getValue("k");
if(iAmInterestedInThisK(k)) {
String v = atts.getValue("v");
doSomethingWithThisV(v);
}
}
}
关于java - SAX 解析器和 XAPI xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10984954/
本文整理了Java中xapi.util.X_Util类的一些代码示例,展示了X_Util类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目
当我发送此示例语句时,当我查看 LRS 中的信息时,动词不会显示。 Actor 和其他信息显示正确。有人可以告诉我我可能做错了什么吗?谢谢。 Simple Statement function
本文整理了Java中xapi.util.X_Util.equal()方法的一些代码示例,展示了X_Util.equal()的具体用法。这些代码示例主要来源于Github/Stackoverflow/M
本文整理了Java中xapi.util.X_Util.rethrow()方法的一些代码示例,展示了X_Util.rethrow()的具体用法。这些代码示例主要来源于Github/Stackoverfl
本文整理了Java中xapi.collect.X_Collect.newStringMultiMap()方法的一些代码示例,展示了X_Collect.newStringMultiMap()的具体用法。
本文整理了Java中xapi.collect.X_Collect.newStringMap()方法的一些代码示例,展示了X_Collect.newStringMap()的具体用法。这些代码示例主要来源
本文整理了Java中xapi.collect.X_Collect.newDictionary()方法的一些代码示例,展示了X_Collect.newDictionary()的具体用法。这些代码示例主要
我试图更好地了解xAPI/Tin Can的工作方式(此后将其称为xAPI) 以前,我是为SCORM 1.2 LMS开发的,其中有“记录”,例如:每个内容包的 Raw尝试,状态和 Raw Score 。
我想用 SAXParser 解析 XAPI xml。但现在我遇到了问题。 首先是一段 xml: 还有一段我的 SAXParser 代码: public void startEle
我是 xAPI/TinCan API 的新手,所以我的问题可能有点笼统,但到目前为止我还没有找到任何可以帮助我的东西。我认为可以将 xAPI 集成到 Unity 项目(游戏或模拟)中,但我该怎么做呢?
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我是一名优秀的程序员,十分优秀!