0

How can i extract an xml element from a java object. for example i have an object of java.lang.Object that contain xml file content at below:

<?xml version="1.0" encoding="UTF-8"?>
<custom:a ...>
 <custom:b...>
   .....
 </custom:b>
</custom:a>

i want to extract <custom:b..> element. please guide me!

Ramtin Ramtin
  • 173
  • 3
  • 12
  • Is the object itself a string? Does the object contain a string where the xml is? – Zavior Sep 22 '13 at 06:28
  • 2
    _How_ does your `Object` contain XML? The object must be some other subclass of `Object`, and without knowing that nobody can help you. It could be a `String` containing the serialized XML, or it could be a parsed element tree. – Jim Garrison Sep 22 '13 at 06:29
  • In any case, there are literally hundreds of questions about this very subject on SO already. – Zavior Sep 22 '13 at 06:29
  • i can convert his object to string using this code String_content= new String((byte[])resource.getContent()); resource is a xml file for example wsdl document – Ramtin Ramtin Sep 22 '13 at 06:30
  • i confused that which way is better for me! because i want extract an element by QName (custom:a). i create a dom.document of my object but it return element by tagname. i dont know how return element by QName in it! – Ramtin Ramtin Sep 22 '13 at 06:38

0 Answers0