In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what is the use of the Javasax parser in Java, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
SAX (a simple API for XML) is a parser for XML documents based on events. Unlike DOM parsers, SAX parsers create no parse trees. SAX is a streaming interface for XML, which means that the SAX application is used to receive event notification about the elements of the XML document being processed, attributes, starting sequentially each time at the top of the document, and ending the root element with the closure.
Read the XML file from top to bottom to form a well-structured XML document markup
Tokens are processed in the same order, and they appear in the document
Report applications because of the nature of the tags encountered by the parser where they appear
The application provides the necessary parser registered "event" handlers
As a tag identification, the information related to the callback method in the handler is called
When will you use it?
When you should use the SAX parser:
Can be processed from top to bottom in XML documents in a linear manner
The file is not deeply nested
Dealing with a very large XML document, the DOM tree takes up too much memory. A typical implementation of DOM uses 10 bytes of memory to represent a byte of XML
Part of the XML document involved in solving the problem
The data is available, as long as it is seen by the parser, such a SAX can be well used to reach the XML document of the stream
Shortcomings of SAX
It is a XML document that only enters to handle random access.
If the data analyzer you need to track has seen or changed the order of the items, you must write your own code and data store
ContentHandler interface
This interface specifies that the SAX parser is used to notify the XML document that you have seen the callback method of the widget application.
VoidstartDocument ()-the call is at the beginning of a file.
VoidendDocument ()-the call is at the end of a file.
VoidstartElement (Stringuri,StringlocalName,StringqName,Attributesatts)-the call is at the beginning of an element.
VoidendElement (Stringuri,StringlocalName,StringqName)-call at the end of a component.
Voidcharacters (char [] ch,intstart,intlength)-called when character data is present.
VoidignorableWhitespace (char [] ch,intstart,intlength)-called when DTD is current and ignore whitespace encounters.
VoidprocessingInstruction (Stringtarget,Stringdata)-called when processing the approval of an instruction.
VoidsetDocumentLocator (Locatorlocator))-provides locators that can be used to identify locations in a document.
VoidskippedEntity (Stringname)-called when an unresolved entity encounters.
VoidstartPrefixMapping (Stringprefix,Stringuri)-when a new namespace mapping definition is called.
VoidendPrefixMapping (Stringprefix)-called when a namespace definition ends its scope.
Attribute interface
This interface specifies the method used to handle attributes connected to an element.
IntgetLength ()-returns the number of attributes.
StringgetQName (intindex)
StringgetValue (intindex)
StringgetValue (Stringqname)
The above is all the content of the article "what is the use of Javasax parsers in Java?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.