1

I have:

<root>
<element1 attribute11="first1" attribute12="second1">value1</element1>
<element2 attribute21="first2" attribute22="second2">value2</element2>
<element3>
    <element31 attribute311="first31" attribute312="second31">value31</element31>
    <element32 attribute321="first32" attribute322="second32">value32</element32>
</element3>
</root>

I want to print:

element1=value1 
attribute11=first1
attribute12=second1
element2=value2 
attribute21=first2
attribute22=second2
element31=value31 
attribute311=first31
attribute312=second32
element31=value31 
attribute321=first32
attribute322=second31

I could achieve this using DOM:

for (Element element : $(myXml).find("*")) {
   if (!element.hasChildNodes()){
         System.out.println("Element: "+element.getNodeName()+"="+$(element).text());
   }
   NamedNodeMap attributesList = element.getAttributes();
   for (int j = 0; j < attributesList.getLength(); j++) {
   System.out.println("Attribute: "
                        + attributesList.item(j).getNodeName() + "="
                        + attributesList.item(j).getNodeValue());
   }
}

But i want do same thing without using DOM and using only joox

Thanks for help!

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
jechaviz
  • 551
  • 1
  • 9
  • 23

1 Answers1

0

Unfortunately, there is no simple way to loop over attributes in jOOX 1.1. There's a pending feature request #16 to improve this. For now, you'll probably have to resort to the DOM API

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509