Re: [Simple-support] Get element value with specific attribute value
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2012-04-30 09:19:58
|
XPath support is limited so you can't actually do this. There are a number of ways to do this, you can use a Map with
@ElementMap(key="att", inline=true)Map<String, String> atts;
Here you just do atts.get("1");
You can also use a Strategy and collect every attribute in the session Map that is passed to the Strategy instance.
Then do the following with the @Commit attribute.
@Commitpublic void commit(Map session) { att1 = session.get("my.key.for.att1");}
See the documentation.
Niall
--- On Sun, 29/4/12, Shay Hazan <sha...@to...> wrote:
From: Shay Hazan <sha...@to...>
Subject: [Simple-support] Get element value with specific attribute value
To: sim...@li...
Received: Sunday, 29 April, 2012, 3:13 AM
Hi,
I have the following xml:
<a>
<b att1="1">bbbb</b>
<b att1="2">cccc</b>
</a>
How can I get the element "b" value with the attribute value "1" (bbbb).
I tried to configure the class "A" with the member "B" as below, but it doesn't work.
public class A
{
@Element(name="B")
@Path("[@att1=\"1\"]")
private String B;
}
Any suggestions ?
10x,
Shay
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|