当前位置:网站首页>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
边栏推荐
- Golang implements a five insurance and one gold calculator with web interface
- decast id.var measure. Var data splitting and merging
- AUTOSAR from introduction to mastery 100 lectures (52) - diagnosis and communication management function unit
- ECDSA signature verification principle and C language implementation
- CMSIS cm3 source code annotation
- MySQL 8.0.11下载、安装和使用可视化工具连接教程
- JDBC connection pool
- hbuilderx + uniapp 打包ipa提交App store踩坑记
- 100 GIS practical application cases (53) - making three-dimensional image map as the base map of urban spatial pattern analysis
- Three channel ultrasonic ranging system based on 51 single chip microcomputer (timer ranging)
猜你喜欢

Install nngraph

Read the data in Presto through sparksql and save it to Clickhouse

Free and open source intelligent charging pile SaaS cloud platform of Internet of things

Navicat远程连接数据库 出现 1130- Host xxx is not allowed to connect to this MySQL server错误

C语言之字符串与字符数组的区别
![[untitled] PID control TT encoder motor](/img/ce/942a0b87994699f73da215e7cad2a1.png)
[untitled] PID control TT encoder motor

X509 parsing

AUTOSAR from introduction to mastery lecture 100 (84) - Summary of UDS time parameters

数据仓库—什么是OLAP

AUTOSAR from introduction to mastery 100 lectures (51) - AUTOSAR network management
随机推荐
The first lesson is canvas, showing a small case
Hanlp word splitter (via spark)
AUTOSAR from introduction to mastery 100 lectures (81) - FIM of AUTOSAR Foundation
AUTOSAR from introduction to mastery 100 lectures (87) - key weapon of advanced EEA - AUTOSAR and DDS
Data warehouse - what is OLAP
JDBC connection pool
100 GIS practical application cases (51) - a method for calculating the hourly spatial average of NC files according to the specified range in ArcGIS
Free and open source intelligent charging pile SaaS cloud platform of Internet of things
three. JS text ambiguity problem
GIS practical tips (III) - how to add legend in CASS?
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)
Design of STM32 multi-channel temperature measurement wireless transmission alarm system (industrial timing temperature measurement / engine room temperature timing detection, etc.)
9419 page analysis of the latest first-line Internet Android interview questions
nodeJs + websocket 循环小案例
【官宣】长沙软件人才实训基地成立!
1130 - host XXX is not allowed to connect to this MySQL server error in Navicat remote connection database
MySQL5.5安装教程
LeetCode_DFS_中等_695.岛屿的最大面积
5 tricky activity life cycle interview questions. After learning, go and hang the interviewer!
安装nngraph