0

i want to ask something.

I found an XML like this one.

<row><?TAGS?><?TAG 024?><?END-TAGS?>
<entry colname="COL1">1</entry>
<entry colname="COL2">2</entry>
<entry colname="COL3">3</entry>
</row>

Do you know how to get all TAG values inside <?TAGS?>? What's that XML bracket <??> for?

For now I am using JAXB annotations and cannot get those tags.

Thanks :)

Thomas Fritsch
  • 9,639
  • 33
  • 37
  • 49

1 Answers1

2

The <?anything?> parts are XML processing instructions.

Unmarshalling:

As far as I know JAXB alone doesn't support processing instructions during unmarshalling. They are just ignored.

However, according to the answers to this question you can get them by using JAXB together with either StAX or SAX.

Marshalling:

According to this answer you can tell the JAXB marshaller to insert your XML processing instructions at the beginning of the XML output. Like this:

Marshaller marshaller = ...;
marshaller.setProperty("com.sun.xml.bind.xmlHeaders",
        "<?TAGS?><?TAG 024?><?END-TAGS?>");
Thomas Fritsch
  • 9,639
  • 33
  • 37
  • 49