ksoap2 相当于 didStart/didEndElement?
我今天的问题是,我很好奇在 java
中是否存在使用 ksoap2
库逐个解析元素的近亲和/或等价物。
以 objective-c
为例:
public void didEndElement(args....){
if occurring element is thisElement
//do something with the value in the element
}
public void didStartElement(args....){
if occurring element is thisElement
//do something with the value in the element
}
而在 java
中
SoapObject foo = (SoapObject)bar.getProperty(enum);
aString = foo.getProperty(enum);
aNotherString = foo.getProperty(anotherEnum);
,所以,基本上,我们想要做的是
即兴创作java
语法:
if(currentElement == "myElement")
aVar = valueInElement;
// or
a[1] = valueInElement;
我知道这可能要求很多,但是如果可能的话,请提供任何指向我可以获得有关此信息的信息的指针或提示。
my question for today is that i'm curious about if there is a close relative and/or equivalence in java
using the ksoap2
-library to parse element-by-elements.
In objective-c
for example:
public void didEndElement(args....){
if occurring element is thisElement
//do something with the value in the element
}
public void didStartElement(args....){
if occurring element is thisElement
//do something with the value in the element
}
While in java
SoapObject foo = (SoapObject)bar.getProperty(enum);
aString = foo.getProperty(enum);
aNotherString = foo.getProperty(anotherEnum);
So, basically, what we want to do is,
improvised java
syntax:
if(currentElement == "myElement")
aVar = valueInElement;
// or
a[1] = valueInElement;
I know that this might a be a lot to ask for, but any pointers or hints to where i can attain any information about this, if it is possible at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 SAX 解析器可以帮助您。如以下链接所示: http://www.androidpeople.com/android- xml-parsing-tutorial-using-saxparser
在那里,创建了一个名为 MyXmlHandler 的类。它扩展了 DefaultHandler 类并允许您重写 startElement 和 endElement 方法。
互联网上有很多教程向您展示如何使用此方法。链接中的格式非常糟糕,必须找到更好的格式。
I think the SAX Parser can help you with that. As in this link: http://www.androidpeople.com/android-xml-parsing-tutorial-using-saxparser
There, a class named MyXmlHandler is created. This one extends the DefaultHandler class and allows you to override the startElement and endElement methods.
There are a lot of tutorials spread out across the internet wich show you how to use this method. The formatting in the link is quite bad, there's gotta be a better one to find.