Questions tagged [jxpath]

JXPath applies XPath expressions to graphs of objects of all kinds: JavaBeans, Maps, Servlet contexts, DOM etc, including mixtures thereof.

JXPath is a Java package that enables extraction of data from hierarchical data structures using XPath notation. JXPath can apply XPath expressions to graphs of objects of all kinds: JavaBeans, Maps, Servlet contexts, DOM etc, including mixtures thereof.

Example:

Address address = (Address)JXPathContext.newContext(vendor).
         getValue("locations[address/zipCode='90210']/address");

This XPath expression is equivalent to the following Java code:

Address address = null;
Iterator it = vendor.getLocations().iterator();
while (it.hasNext()){
    Location location = (Location)it.next();
    String zipCode = location.getAddress().getZipCode();
    if (zipCode.equals("90210")){
      address = location.getAddress();
      break;
    }
}
50 questions
0
votes
0 answers

Newbi - Dividing two JXPATH queries

I have two query JXpath returning me the right value count(./productItemList/countryOfOrigin) - Returning me 5 count(./productItemList/customerOrderLine) - Returing me 4 I am looking to combine these queries so I…
ben
  • 1
0
votes
2 answers

How to get the first elements of object arrays in a list with jxpath?

List alma = new ArrayList(); alma.add(new Object[] { "alma", "korte" }); alma.add(new Object[] { "alma2", "korte2" }); alma.add(new Object[] { "alma3", "korte3" }); JXPathContext context = JXPathContext.newContext(alma); List result =…
Gábor Lipták
  • 9,646
  • 2
  • 59
  • 113
0
votes
0 answers

Problems with migration apache-poi from 3.17 to 4.1.1

After updating Apache POI from 3.17 to 4.1.1 i'm getting this error message: org.apache.commons.jxpath.JXPathNotFoundException: No value for xpath: /xxxx/value at …
aanot
  • 1
  • 2
0
votes
1 answer

JXPath : how to query all keys from a map

I am trying to query a property of all items in a map. I can do it with a collection, but it does not work for map. I have tries many variation, but did not find a way to get all ids of objects in map. See complete code example below. import…
Filip
  • 906
  • 3
  • 11
  • 33
0
votes
1 answer

JXPath expression with escape character '#' giving issues

Input JSON : [ {"Activity":"yes","SBNumber":"123"}, {"Activity":"yes","SB#":"123"} ] JXPath Expressions: //works : returns "123" JXPathContext.newContext(input).getValue("//*/SBNumber") //fails: throwing…
prash
  • 896
  • 1
  • 11
  • 18
0
votes
1 answer

Fastest and Efficient way of parsing XML data without schema bounded

Currently I am processing a XML data (in MBs) as follows, Create DOM object for XML record. Apply XPath queries on DOM object to retrieve fields. My XML is as follows, A
Viswa
  • 1,357
  • 3
  • 18
  • 30
0
votes
1 answer

JXPathException 'No write method' error

I have two java components. First one is analysing MyTree object and generating tasks with JXPathContext's to remove. Then tasks are sent to second one. Second component is executing tasks. During execuction I receive following…
osjo
  • 131
  • 6
0
votes
1 answer

Translate XPath to JXPath

I've got the following XML: ID TYPE
Tinki
  • 1,486
  • 1
  • 21
  • 32
0
votes
1 answer

JXPath - xpath evaluation on a java objects tree structure

I have a java objects tree structure (model) created using java Lists and Maps, and I want to evaluate an xpath of the following sort: name[/type='theType'] This xpath expression needs both the context node and the root node. However, I've found no…
xarx
  • 627
  • 1
  • 11
  • 27
0
votes
2 answers

How to make jxpath read @xmlelement name attribute instead of actual field name?

I have a class with a field which looks like this @XmlElement(name = "Name", namespace = "a:b:c:1", required = true) protected String firstName I want to use JXPath like this String name = (String) context.getValue("Name"); But it doesn't…
Sujay DSa
  • 1,172
  • 2
  • 22
  • 37
0
votes
1 answer

How to get one attribute from list of custom objects

Java - JxPath - Spring I have List myClassList filled with MyClass objects. I am trying to find a cleanest and fastest way to get Set a property out of myClassList. class MyClass{ private String a; private String b; //…
d-man
  • 57,473
  • 85
  • 212
  • 296
0
votes
1 answer

How to read XML attribute values using JXPathContext if reference is missing

Given following XML, we are using JXPathContext to create Java object out of it. XXXX
RKodakandla
  • 3,318
  • 13
  • 59
  • 79
0
votes
1 answer

jxPath Getting an Object from a list based on value in a Map

So I have an object Structure like the following: I have a Person Object which has a list of Friends (named friends in Person) - That list of Friends has a Map (named information) - The map has a Key of 'age' and a value of an string So I am…
mstelz
  • 610
  • 4
  • 9
  • 19
0
votes
1 answer

JXPath getValue results include results from previous searches as well

I am using JXPathContext to search through the Java Object using XPath. I have the following code. The class department has an employees collection. public List getEmployeesByDepartment(String departmentName, Company company){ …
waqas
  • 124
  • 1
  • 10
0
votes
1 answer

Java JXPath iterating through List

JXPath search in list of bean for rateCode value by empty iterator. I have list of beans where i want to fetch all items having rateCode=R1 following is my code. class MyBean{ private String rateCode; public String getRateCode(){ return…
d-man
  • 57,473
  • 85
  • 212
  • 296