Android XML Document Append buildPlayerNode(Document doc, String user, String addy, double lat, double lng)

Here you can find the source of buildPlayerNode(Document doc, String user, String addy, double lat, double lng)

Description

build Player Node

Declaration

public static Node buildPlayerNode(Document doc, String user,
            String addy, double lat, double lng) 

Method Source Code

//package com.java2s;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class Main {
    public static Node buildPlayerNode(Document doc, String user,
            String addy, double lat, double lng) {
        //Build out content
        Element player = doc.createElement("player");
        Node name = doc.createElement("name");
        name.setTextContent(user);/*from ww  w.jav a 2 s. c  o  m*/
        Node id = doc.createElement("id");
        id.setTextContent(addy);
        Node loc = doc.createElement("location");
        Node lati = doc.createElement("lat");
        lati.setTextContent(String.valueOf(lat));
        Node lngi = doc.createElement("lng");
        lngi.setTextContent(String.valueOf(lng));
        //Append elements to correct places
        loc.appendChild(lati);
        loc.appendChild(lngi);
        player.appendChild(name);
        player.appendChild(id);
        player.appendChild(loc);
        return player;
    }
}

Related

  1. appendTextNode(String tagName, String textContent, Document doc)
  2. createAttribute(Document document, String name, String value)
  3. createElementWithCDATASection(Document document, String name, String value)
  4. createElementWithTextNode(Document document, String name, String value)
  5. createNode(Document d, String nameSpace, String name)