In various interviews, including Java interviews for web developers, XML interview questions are common in interviews for various programming jobs. XML is a mature technology that is often used as a standard for transferring data from one platform to another. XML interview questions include XSLT technology for converting XML files, XPATH, XQuery and other XML technologies and XML basic knowledge, such as DTD or Schema.
This article will see 10 common XML interview questions. Most of these questions are asked in Java interviews, and are also useful in programming interviews in C, C++, Scala or other languages. XML does not rely on other programming languages, and is one of the skills required by programmers, just like SQL, so it makes sense to prepare some XML questions before any technical job interview.
XML Interview Q&A
Below are the interview questions I have listed about XML technology that I often ask. These questions are not difficult but cover some important areas of XML technology, such as DTD, XML Schema, XSLT conversion, XPATH retrieval, XML binding, XML parser, and basic knowledge of XML, such as namespace, verification, attributes, elements, etc.
Question 1: What is XML?
Answer: XML can extend the markup language (Extensible Markup language), and you can extend XML according to your needs. Custom tags such as <books> and <orders> can be easily defined in XML, while predefined tags, such as <p>, must be used in other markup languages such as HTML, and cannot be used. Standardize XML structures using DTD and XML Schema. XML is mainly used for data transmission from one system to another, such as client and server for enterprise-level applications.
Question 2: What is the difference between DTD and XML Schema?
Answer: DTD and XML Schema have the following differences: DTD is not written in XML, while XML Schema itself is an XML file, which means that existing XML tools such as XML parsers can be used to process XML Schema. Moreover, XML Schema is designed after DTD, and it provides more types to map different data types of xml files. DTD is a document type definition (Document Type definition) which is a traditional way to define the XML file structure.
Question 3: What is XPath?
A: XPath is an XML technology used to retrieve elements from an XML document. XML documents are structured, so XPath can locate and retrieve elements, attributes, or values from XML files. In terms of data retrieval, XPath is very similar to SQL, but it has its own syntax and rules. Learn more about how to retrieve data from XML documents using XPath.
Question 4: What is XSLT?
Answer: XSLT is also a commonly used XML technology, which is used to convert an XML file to another XML, HTML or other format. XSLT defines its own syntax, functions and operators in detail for converting XML files. The conversion is usually completed by the XSLT engine, which reads the instructions for XML style sheets or XSL files written in XSLT syntax. XSLT uses recursion heavily to perform transformations. A common use of XSLT is to display data in an XML file as an HTML page. XSLT can also easily convert one XML file into another XML document.
Question 5: What are XML elements and properties
Answer: It is best to give an example to explain. Below is a simple XML snippet.
<Orders><Order id=”123″><Symbol>6758.T</Symbol><Price>2300</Price><Order><Orders>
In the example, id is an attribute of an element, and none of the other elements have attributes.
Question 6: What is well-formed XML
Answer: This question often appears in telephone interviews. A well-formed XML means that the XML document is syntactically correct, such as it has a root element, all open tags are properly closed, attribute values must be quoted, etc. If an XML is not well-formed, it may not be properly processed and parsed by various XML parsers.
Question 7: What is an XML namespace? Why is it important?
Answer: The XML namespace is similar to Java package, and is used to avoid conflicts between tags with the same name from different sources. XML namespace is defined at the top of the XML document using the xmlns attribute, with the syntax as xmlns:prefix='URI'. prefix is used with actual tags in XML documents. The following example is the use of XML namespace.
<root xmlns:inst=”http://instruments.com/inst”<inst:phone><inst:number>837363223</inst:number></inst:phone></root>
Question 8: What is the difference between DOM and SAX parser
Answer: This is another common interview question, which not only appears in XML interview questions, but also in Java interviews. The main difference between DOM and SAX parsers is the way they parse XML documents. When parsing with DOM, XML documents are loaded into memory as a tree structure, and SAX is an event-driven parser. This question is answered in more detail to see the difference between DOM and SAX parser.
Question 9: What is XML CDATA
Answer: This question is simple and important, but many programmers do not have a deep understanding of it. CDATA refers to character data, which has special instructions parsed by XML parser. The XML parser parses all text in an XML document, such as <name>This is name of person</name>, and the tag value will also be parsed, because the tag value may also contain XML tags, such as <name><firstname>First Name</firstname></name>. The CDATA part will not be parsed by the XML parser. The CDATA part is "
Question 10: What is XML data binding for Java
Answer: Java's XML binding refers to creating classes and objects from XML files and modifying XML documents using the Java programming language. XML-bound Java API, JAXB provides a convenient way to bind XML documents and Java objects. Another optional XML binding method is to use open source libraries such as XML Beans. One of the biggest advantages of XML binding in Java is to use Java programming capabilities to create and modify XML documents.
The above XML interview questions are collected from many programmers, but they are useful for everyone using XML technology. Because XML has platform-independent characteristics, XML technologies such as XPath, XSLT, XQuery are becoming increasingly important, and XML is widely used for cross-platform data transmission. Although XML has disadvantages such as redundancy and large document size, it plays a great role in data transmission between systems where web services and bandwidth and speed are secondary considerations.
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.