troubleshooting Question

Java XML getting Element content as String

Avatar of bored_shiva
bored_shiva asked on
Java
3 Comments1 Solution600 ViewsLast Modified:
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros