当前位置:网站首页>XML
XML
2022-04-23 13:11:00 【ArchieSean】
XML
The blogger's name is taken from 《 Shaun the Sheep 》 Shawn the lamb in the , The name is : Sean , Transliterated as Sean, Take your own last name : Archie , In order to conform to our reading habits , Connected to form ArchieSean. The blogger is currently a junior reading , Aiming to build blog into a technical stack of personal online notes , Be convenient for yourself and others . If there are any mistakes in the blog , Please point out , Thank you. .
List of articles
Concept
1. Concept : Extensible Marhup Language Extensible markup language
* Scalable : The tags are all custom .
2. function :
* Store the data
* 1. The configuration file
* 2. To transmit in a network
3.xml And html The difference between :
1.xml The tags are all custom ,html Labels are predefined .
2.xml The grammar is strict ,html Loose grammar
3.xml The data of village school is ,html It's a way to show data
grammar
* Basic grammar :
1. xml The suffix of the document .xml
2. xml The first line must be defined as a document declaration
3. xml There is and only one root tag in the document
4. The attribute value must be in quotation marks ( Single and double ) Lead up
5. Label must be closed correctly ( Double label )
6. xml Label names are case sensitive
* Quick start :
for example : <?xml version = '1.0' ?>
<users>
<user id='1'>
<name>zhangsan</name>
<age>23</age>
<gender>male</gender>
</user>
<user id='2'>
<name>lisi</name>
<age>24</age>
<gender>female</gender>
</user>
</users>
* Part of the :
1. The document statement
1. Format :<?xml Property list ?>
2. Property list :
*version: Version number
*encoding: Encoding mode . Tells the parsing engine what character set the current document uses , The default value is :ISO-8859-1
*standalone: Is it independent
* Cancel :
*yes: Don't rely on other files
*no: Rely on other files
2. Instructions ( understand ): Combine css Of
* <?xml-stylesheet type="text/css" href="a.css" ?>
3. label : Label name custom
* The rules :
* Names can contain letters 、 Numbers and other characters .
* The name cannot start with a numeric punctuation mark
* The name cannot be in letters xml( perhaps XML、Xml wait ) Start
* The name cannot contain spaces
4. attribute :
id Attribute is the only .
5. Text :
CDATA District : The data in this area will be displayed as is
* <![CDATA[ data ]]>
* constraint : Regulations xml Rules for writing documents
* As users of the framework ( The programmer ):
1. In the xml Constraint document is introduced in
2. Be able to simply read and understand the document
* classification :
1.DTD: A simple constraint technique
2.Schema: A complex constraint technique
*DTD:
* introduce dtd Document to xml In the document
* Inside dtd: Define the constraint rules in xml In the document ( understand )
* external dtd: Define the rules of constraint in the external dtd in
* Local :<!DOCTYPE Root sign SYSTEM "dtd The location of the file “>
* The Internet :<!DOCTYPE Root sign PUBLIC “dtd File name ” “dtd The location of the file URL">
analysis :
-
operation xml file , Read the data in the document into memory
operation xml file :
1. analysis ( Read ): Read the data in the document into memory
2. write in : Save the data in memory to xml In the document . Persistent storage .analysis xml The way :
1.DOM: Load markup language documents into memory at one time , Form a... In memory dom Trees
* advantage : It is easy to operate , You can do CRUD All operations
* shortcoming : Occupy memory
2.SAX: Read line by line , Event driven .
* advantage : Do not occupy memory
* shortcoming : Can only read , You can't add, delete, or modifyxml Common parsers :
1.JAXP:sun Company supplied parsers , Support dom and sax Two thoughts ( understand )
2.DOM4J: A very good parser
3.Jsoup:jsoup Is a Java Of HTML Parser , Can directly parse a URL Address 、HTML Text content . It provides a very labor-saving API, It can be done by DOM,CSS And similar to jQuery To extract and manipulate data .
4.PULL: The built-in parser of Android operating system ,sax The way of .Jsoup
jsoup Is a Java Of HTML Parser , Can directly parse a URL Address 、HTML Text content . It provides a very labor-saving API, It can be done by DOM,CSS And similar to jQuery To extract and manipulate data .
Quick start :
* step :
1. Import jar package
2. obtain Document object
3. Get the corresponding label
4. get data
* Code :
// obtain xml The path of
String path =JsoupDemo1.class.getClassLoader().getResource("student.xml").getPath();
// obtain document file , according to xml Document access
Document parse = Jsoup.parse(new File(path), "utf-8");
//3. Get element object
Elements name = parse.getElementsByTag("name");
System.out.println(name.size());
Use of objects :
1.Jsoup: Tool class , Can be parsed html perhaps xml file , return Document
*parse: Can be parsed html perhaps xml file , return Document
* parse (File in, String charsetName)
* parse(String html): analysis xml or html character string .
* parse(URL url,int timeoutMillis): Get the specified... Through the network path html or xml Document object for .
2.Document: Document object , Represents... In memory dom Trees
obtain Element object
getElementsById("id"): according to id Get the collection of label elements .
getElementsByTag("name"): Get the collection of tag elements according to the tag name .
getElementsByAttribute(String key): Get the element object according to the attribute name .
getElementsByAttributeValue(String key,String value): Get the element object set according to the corresponding attribute name and attribute value .
3.Elements: Elements Element A collection of objects . Can be viewed as ArrayList To use
4.Element: Element object
1. Get child element object
1. getElementById(String id): according to id Property value gets unique element object .
2. getElementsByTag("name"): Get the collection of tag elements according to the tag name .
3. getElementsByAttribute(String key): Get the element object according to the attribute name .
4. getElementsByAttributeValue(String key,String value): Get the element object set according to the corresponding attribute name and attribute value .
2. Get attribute value
1.String attr(String key): Get the property value according to the property name .
3. Get text content .
1.String text(): Get text content
2.String html(): Get all the contents of the label body ( Including the string content of the sub tag )
5.Node: Node object
1. yes Document and Element Parent class of
Quick query
1.selector: Selectors
* Method used :Elements select(String cssQuery)
grammar : Reference resources Selector Syntax defined in class
2.XPath:XPath, That is to say XML Path to the language (XMLPathLanguage), It's a way to determine XML The language of a part of a document
* Use Jsoup Of Xpath Need extra import jar package
* Inquire about w3cshool Reference manual , Use xpath The syntax of complete query
版权声明
本文为[ArchieSean]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231306322980.html
边栏推荐
- [notes de marche]
- ECDSA signature verification principle and C language implementation
- MySQL 8.0.11下载、安装和使用可视化工具连接教程
- 2021年6月程序员工资统计,平均15052元,你拖后腿了吗?
- 2020年最新字节跳动Android开发者常见面试题及详细解析
- [untitled] PID control TT encoder motor
- C语言之字符串与字符数组的区别
- Analysis of the latest Android high frequency interview questions in 2020 (BAT TMD JD Xiaomi)
- three. JS text ambiguity problem
- Golang implements MD5, sha256 and bcrypt encryption
猜你喜欢
Customize classloader and implement hot deployment - use loadclass
jmeter操作redis
PC starts multiple wechat at one time
你和42W奖金池,就差一次“长沙银行杯”腾讯云启创新大赛!
HQL find the maximum value in a range
melt reshape decast 长数据短数据 长短转化 数据清洗 行列转化
2020年最新字节跳动Android开发者常见面试题及详细解析
ESP32 VHCI架构传统蓝牙设置scan mode,让设备能被搜索到
CMSIS cm3 source code annotation
Record Alibaba cloud server mining program processing
随机推荐
Go language slicing operation
Recovering data with MySQL binlog
STM32 tracking based on open MV
AUTOSAR from introduction to mastery lecture 100 (84) - Summary of UDS time parameters
SQL exercise question 1
100 GIS practical application cases (51) - a method for calculating the hourly spatial average of NC files according to the specified range in ArcGIS
web三大组件之Filter、Listener
Wu Enda's programming assignment - logistic regression with a neural network mindset
decast id.var measure. Var data splitting and merging
Proteus 8.10 installation problem (personal test is stable and does not flash back!)
Conflict between Mui picker and drop-down refresh
three.js文字模糊问题
EMMC / SD learning notes
【动态规划】221. 最大正方形
Async void provoque l'écrasement du programme
ESP32 VHCI架构传统蓝牙设置scan mode,让设备能被搜索到
mui + hbuilder + h5api模拟弹出支付样式
Custom nail robot alarm
解决虚拟机中Oracle每次要设置ip的问题
Community version Alibaba MQ ordinary message sending subscription demo