Click here to Skip to main content
15,889,867 members
Home / Discussions / Java
   

Java

 
GeneralRe: how to read mifare card using java smartcardio? Pin
Richard MacCutchan20-Sep-14 21:24
mveRichard MacCutchan20-Sep-14 21:24 
Questiondate validation Pin
20siva20-Sep-14 4:43
20siva20-Sep-14 4:43 
AnswerRe: date validation Pin
Richard MacCutchan20-Sep-14 20:48
mveRichard MacCutchan20-Sep-14 20:48 
GeneralRe: date validation Pin
20siva21-Sep-14 4:11
20siva21-Sep-14 4:11 
GeneralRe: date validation Pin
Richard MacCutchan21-Sep-14 7:48
mveRichard MacCutchan21-Sep-14 7:48 
QuestionEncoding / Decoding 7 bit User Data for SMS PDU (PDU Bit Packer) using java Pin
Member 1104686618-Sep-14 20:54
Member 1104686618-Sep-14 20:54 
AnswerRe: Encoding / Decoding 7 bit User Data for SMS PDU (PDU Bit Packer) using java Pin
Richard MacCutchan18-Sep-14 22:20
mveRichard MacCutchan18-Sep-14 22:20 
QuestionJSoup and XSoup "Couldn't parse query" Pin
DevvsBugs18-Sep-14 5:13
DevvsBugs18-Sep-14 5:13 
What am I trying todo: I request the document from a website with jsoup and then I try to get different kind of information from it. So far it worked with like getting the text of a tag but now I have a few H2 tags which contains headlines of different Information structures. I need to check if this H2 tag a specific text and then get the text of the parent html node.

This is the code I try to execute
Java
String expression = "//h2[text()='Synopsis']";
System.out.println(Xsoup.compile(expression).evaluate(doc).get());


and this is the exception I get
org.jsoup.select.Selector$SelectorParseException: Could not parse query 'h2[text()='Synopsis']': unexpected token at 'text()='Synopsis''
at us.codecraft.xsoup.xevaluator.XPathParser.byFunction(XPathParser.java:225)
at us.codecraft.xsoup.xevaluator.XPathParser.consumePredicates(XPathParser.java:202)
at us.codecraft.xsoup.xevaluator.XPathParser.findElements(XPathParser.java:138)
at us.codecraft.xsoup.xevaluator.XPathParser.parse(XPathParser.java:51)
at us.codecraft.xsoup.xevaluator.XPathParser.parse(XPathParser.java:375)
at us.codecraft.xsoup.xevaluator.XPathParser.combinator(XPathParser.java:85)
at us.codecraft.xsoup.xevaluator.XPathParser.parse(XPathParser.java:49)
at us.codecraft.xsoup.xevaluator.XPathParser.parse(XPathParser.java:375)
at us.codecraft.xsoup.Xsoup.compile(Xsoup.java:27)
at de.daraku.coding.daraku_mal_api.Test.TestParseAnimeSearch.TestSynopsis(TestParseAnimeSearch.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
For the last 4 hours and tried like 30 different xpath statements like the one above I'm at a loss here and can't think of anything more I could try. Every selution that goes remotely in this kind of direction I tried returned null, something entirely different as I expected or with the exception you see above.

here is an example that actually works but as I said before its quite easy
Java
Xsoup.compile("//div[@id='contentWrapper']/h1/text()")


and yes the H2 tag with the text Synopsis exists, If I requests a list of all H2 tags like this
Java
String expression = "//h2";
List<String> list = Xsoup.compile(expression).evaluate(doc).list();

there is a list entry with Synopsis as tag at the 5th position. But since I can't really say that every H2 tag will be displayed its hard to say that its always on the 5th position.

I chose XSoup because it is XPath based on JSoup and since I already use Jsoup, why don't combine it and save some time (thats at least what I thought)

Is Anyone here that can help me? Is it only a problem of XSoup, Or is my statement just wrong? Or is there an even better way to do this?
Generalhow to close the modal dialog so that it return to parent window by using button ? Pin
Member 1087484117-Sep-14 1:08
Member 1087484117-Sep-14 1:08 
GeneralRe: how to close the modal dialog so that it return to parent window by using button ? Pin
Richard MacCutchan17-Sep-14 2:43
mveRichard MacCutchan17-Sep-14 2:43 
GeneralRe: how to close the modal dialog so that it return to parent window by using button ? Pin
Member 1115477415-Oct-14 0:09
Member 1115477415-Oct-14 0:09 
QuestionPulling data from QC and displaying it as graphically Using Java Pin
Member 1108581215-Sep-14 23:23
Member 1108581215-Sep-14 23:23 
QuestionCrossword Pin
Madhusudan H15-Sep-14 10:29
Madhusudan H15-Sep-14 10:29 
AnswerRe: Crossword Pin
Richard MacCutchan15-Sep-14 21:29
mveRichard MacCutchan15-Sep-14 21:29 
Questionneed help for creation of graph in main memory and traversing the graph in java Pin
Member 1108183214-Sep-14 11:05
Member 1108183214-Sep-14 11:05 
AnswerRe: need help for creation of graph in main memory and traversing the graph in java Pin
Richard MacCutchan14-Sep-14 23:03
mveRichard MacCutchan14-Sep-14 23:03 
Questionjob Pin
Member 1107165610-Sep-14 7:41
Member 1107165610-Sep-14 7:41 
AnswerRe: job Pin
Richard MacCutchan10-Sep-14 21:08
mveRichard MacCutchan10-Sep-14 21:08 
QuestionShare object in same JVM Pin
Shivanand Gupta3-Sep-14 22:15
Shivanand Gupta3-Sep-14 22:15 
AnswerRe: Share object in same JVM Pin
Richard MacCutchan3-Sep-14 23:04
mveRichard MacCutchan3-Sep-14 23:04 
GeneralRe: Share object in same JVM Pin
Shivanand Gupta4-Sep-14 20:44
Shivanand Gupta4-Sep-14 20:44 
GeneralRe: Share object in same JVM Pin
Richard MacCutchan4-Sep-14 21:13
mveRichard MacCutchan4-Sep-14 21:13 
AnswerRe: Share object in same JVM Pin
jschell5-Sep-14 10:22
jschell5-Sep-14 10:22 
GeneralRe: Share object in same JVM Pin
Shivanand Gupta23-Sep-14 0:33
Shivanand Gupta23-Sep-14 0:33 
Questionbuilding translator software Pin
Member 1104219227-Aug-14 21:56
Member 1104219227-Aug-14 21:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.