Is it possible, to address a nodes Attributes and Value with SimpleXML? For example in tag "from":
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from name="test">Jani</from>
<heading>Reminder</heading>
<body>Dont forget me this weekend!</body>
</note>
I couldn't find a way to address the content of the node in my code. My example code for this XML would be:
public class Note
{
@Element(name = "to")
private String to;
@Element(name = "from")
private Sender from;
@Element(name = "heading")
private String heading;
@Element(name = "body")
private String body;
}
public class Sender
{
private String content;
@Attribute(name = "name")
private String attribute;
}
Now im looking for a annotation for Sender.content which addresses the value note/from/Jani
According to the official documentation, you can use the annotation
@Text:Example below:
Adding text and attributes to elements
Your code will then look like:
http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php