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