当前位置:网站首页>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
边栏推荐
- MySQL5.5安装教程
- JMeter operation redis
- 100 GIS practical application cases (52) - how to keep the number of rows and columns consistent and aligned when cutting grids with grids in ArcGIS?
- "Play with Lighthouse" lightweight application server self built DNS resolution server
- Read the data in Presto through sparksql and save it to Clickhouse
- Golang implements a five insurance and one gold calculator with web interface
- Design and manufacture of 51 single chip microcomputer solar charging treasure with low voltage alarm (complete code data)
- hbuilderx + uniapp 打包ipa提交App store踩坑记
- Ffmpeg common commands
- Analysis of the latest Android high frequency interview questions in 2020 (BAT TMD JD Xiaomi)
猜你喜欢

十万大学生都已成为猿粉,你还在等什么?

Imx6ull QEMU bare metal tutorial 2: usdhc SD card

你和42W奖金池,就差一次“长沙银行杯”腾讯云启创新大赛!

在 pytorch 中加载和使用图像分类数据集 Fashion-MNIST

1130 - host XXX is not allowed to connect to this MySQL server error in Navicat remote connection database

PC starts multiple wechat at one time

three.js文字模糊问题

Design of body fat detection system based on 51 single chip microcomputer (51 + OLED + hx711 + US100)

8086 of x86 architecture

LeetCode_DFS_中等_695.岛屿的最大面积
随机推荐
51 single chip microcomputer stepping motor control system based on LabVIEW upper computer (upper computer code + lower computer source code + ad schematic + 51 complete development environment)
The use of dcast and melt in R language is simple and easy to understand
[wechat applet] flex layout usage record
ESP32 VHCI架构传统蓝牙设置scan mode,让设备能被搜索到
内核错误: No rule to make target ‘debian/canonical-certs.pem‘, needed by ‘certs/x509_certificate_list‘
AUTOSAR from introduction to mastery 100 lectures (86) - 2F of UDS service foundation
【官宣】长沙软件人才实训基地成立!
Async void caused the program to crash
MySQL basic statement query
Complete project data of UAV apriltag dynamic tracking landing based on openmv (LabVIEW + openmv + apriltag + punctual atom four axes)
7_Addmodule和基因加和法add 得到的细胞类型打分在空间上空转对比
Request和Response及其ServletContext总结
Three channel ultrasonic ranging system based on 51 single chip microcomputer (timer ranging)
Proteus 8.10 installation problem (personal test is stable and does not flash back!)
"Play with Lighthouse" lightweight application server self built DNS resolution server
Imx6ull QEMU bare metal tutorial 2: usdhc SD card
9419页最新一线互联网Android面试题解析大全
“湘见”技术沙龙 | 程序员&CSDN的进阶之路
[Technical Specification]: how to write technical documents?
MySQL -- 16. Data structure of index