Java XML getting Element content as String

I have an XML document that looks like this:
<Penny>
      <Script id="CustomTEST1" ExID="CustomTEST1">
            <Priority>URGENT</Priority>            
                 Ping 152.22.34.12
            <QBE stamp="305419896">
                  <QPT Iterations="200" NumberOfPackets="100" TimeBetweenTrains="1" Destination="147.27.14.8"
                  PacketSize="60" Protocol="ICMP" Tos="0" TTLs="50" SourcePort="7777" DestinationPort="7777"/>
            </QBE>
      </Script>
</Penny>

I want to get everything in the "script" element as one String.
 I can't use getTextContent() because that only returns the text content of the element as a String, so it would only return "URGENT                 Ping 152.22.34.12" in this case, where as I want a text String that would read:

"<Priority>URGENT</Priority> Ping 152.22.34.12<QBE stamp="305419896">      <QPT Iterations="200" NumberOfPackets="100" TimeBetweenTrains="1" Destination="147.27.14.8"                   PacketSize="60" Protocol="ICMP" Tos="0" TTLs="50" SourcePort="7777" DestinationPort="7777"/>      </QBE>"

How do I go about doing that?
Thanks
bored_shivaAsked:
Who is Participating?
 
bored_shivaAuthor Commented:
This rocks, exactly what I was looking for. Thanks.
0
 
Gurvinder Pal SinghCommented:
thanks :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.