1 21 22 package nu.xom.samples; 23 24 import java.math.BigInteger ; 25 26 import nu.xom.Attribute; 27 import nu.xom.Document; 28 import nu.xom.Element; 29 30 31 42 public class FibonacciAttributes { 43 44 public static void main(String [] args) { 45 46 BigInteger low = BigInteger.ONE; 47 BigInteger high = BigInteger.ONE; 48 49 Element root = new Element("Fibonacci_Numbers"); 50 for (int i = 1; i <= 10; i++) { 51 Element fibonacci = new Element("fibonacci"); 52 fibonacci.appendChild(low.toString()); 53 Attribute index = new Attribute("index", String.valueOf(i)); 54 fibonacci.addAttribute(index); 55 root.appendChild(fibonacci); 56 57 BigInteger temp = high; 58 high = high.add(low); 59 low = temp; 60 } 61 Document doc = new Document(root); 62 System.out.println(doc.toXML()); 63 64 } 65 66 } | Popular Tags |