Android examples for XML:XML Tag
Builds XML start tag with name provided.
/*/* ww w. j ava2 s . c o m*/ * Copyright 2016-present Open Networking Laboratory * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //package com.java2s; public class Main { public static void main(String[] argv) { String name = "java2s.com"; System.out.println(buildStartTag(name)); } public static final String NEW_LINE = "\n"; public static final String ANGLE_LEFT = "<"; public static final String ANGLE_RIGHT = ">"; /** * Builds XML start tag with name provided. * * @param name tag name * @return string */ public static String buildStartTag(String name) { return buildStartTag(name, true); } /** * Builds XML start tag with name provided. * * @param name tag name * @param addNewLine option to add new line character after tag * @return string */ public static String buildStartTag(String name, boolean addNewLine) { if (addNewLine) { return (ANGLE_LEFT + name + ANGLE_RIGHT + NEW_LINE); } else { return (ANGLE_LEFT + name + ANGLE_RIGHT); } } }