📄 xmlelement.java
字号:
package XML;
import Utilities.*;
import java.util.*;
public class XMLElement{
private String tag="";
private String value="";
private String xmlStr="";
private String attributes="";
public XMLElement(){
this.tag="";
this.value="";
this.xmlStr="";
}
public XMLElement(String tag){
this.tag=tag;
this.xmlStr="<"+tag;
}
public XMLElement(String tag,String value){
this.tag=tag;
this.value=value;
this.xmlStr="<"+tag;
}
public XMLElement(String tag,String value,Attribute attr){
this(tag,value);
attributes+=" "+attr;
}
public void setTag(String tag){
this.tag=tag;
}
public String getTag(){
return this.tag;
}
public void setValue(String value){
this.value=value;
}
public String getValue(){
return this.value;
}
public void addAttribute(XMLAttribute attr){
this.attributes+=" "+attr;
}
public String toString(){
xmlStr+=this.attributes;
xmlStr+=">"+this.value+"</"+this.tag+">";
return xmlStr;
}
public static void main(String args[]){
XMLElement element=new XMLElement("command","submit");
XMLAttribute attr=new XMLAttribute("msg_fmt",15);
element.addAttribute(attr);
attr.setName("tp_udhi");
attr.setValue(0x40);
element.addAttribute(attr);
attr.setName("msg_content");
attr.setValue("this is a test message");
element.addAttribute(attr);
System.out.println(element);
XMLAttribute[] attributes=XMLAttribute.getXMLAttributes("ip=\"192.168.0.1\" UID=\"dongyu\" PWD=\"hi\" ");
//Attribute atr;
for (int i=0;i<attributes.length;i++){
System.out.println(attributes[i].getName()+ " "+attributes[i].getValue());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -