当前位置:网站首页>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
边栏推荐
- @优秀的你!CSDN高校俱乐部主席招募!
- 4.22 study record (you only did water problems in one day, didn't you)
- Utils of various date conversion
- 100 GIS practical application cases (34) - splicing 2020globeland30
- The use of dcast and melt in R language is simple and easy to understand
- SSM整合之pom.xml
- STD:: shared of smart pointer_ ptr、std::unique_ ptr
- Use Proteus to simulate STM32 ultrasonic srf04 ranging! Code+Proteus
- 鸿蒙系统是抄袭?还是未来?3分钟听完就懂的专业讲解
- JMeter operation redis
猜你喜欢
Complete project data of UAV apriltag dynamic tracking landing based on openmv (LabVIEW + openmv + apriltag + punctual atom four axes)
AUTOSAR from introduction to mastery 100 lectures (52) - diagnosis and communication management function unit
X509 parsing
1130 - host XXX is not allowed to connect to this MySQL server error in Navicat remote connection database
HQL find the maximum value in a range
初鉴canvas,展示个小小的小案例
2021年6月程序员工资统计,平均15052元,你拖后腿了吗?
【动态规划】221. 最大正方形
hbuilderx + uniapp 打包ipa提交App store踩坑记
MySQL 8.0.11下载、安装和使用可视化工具连接教程
随机推荐
mui picker和下拉刷新冲突问题
Use Proteus to simulate STM32 ultrasonic srf04 ranging! Code+Proteus
three.js文字模糊问题
Mui wechat payment pit
Complete project data of UAV apriltag dynamic tracking landing based on openmv (LabVIEW + openmv + apriltag + punctual atom four axes)
Custom nail robot alarm
async void 導致程序崩潰
普通大学生如何拿到大厂offer?敖丙教你一招致胜!
jmeter操作redis
Recovering data with MySQL binlog
Community version Alibaba MQ ordinary message sending subscription demo
2020最新Android大厂高频面试题解析大全(BAT TMD JD 小米)
Read the data in Presto through sparksql and save it to Clickhouse
Mui + hbuilder + h5api simulate pop-up payment style
MySQL -- 16. Data structure of index
[untitled] make a 0-99 counter, P1 7 connected to key, P2 connected to nixie tube section, common anode nixie tube, P3 0,P3. 1. Connect the nixie tube bit code. Each time you press the key, the nixie
Record Alibaba cloud server mining program processing
[walking notes]
5道刁钻的Activity生命周期面试题,学完去吊打面试官!
[notes de marche]