Prev Next

Java / XML

1. What is XML?

XML stands for Extensible Markup language which means you can extend XML based on your needs. You can define custom tags like , etc in XML easily as opposed to other markup languages. The structure of XML can be standardized by making use of DTD and XML Schema. XML is mostly used to transfer data...

Read full answer

2. Difference between DTD and XML Schema.

DTD stands for Document Type definition and was a legacy way to define the structure of XML documents. XML schema is designed after DTD and it offers more types to map different types of data in XML documents. DTD is not written using XML while XML schema are xml documents in itself, which means ...

Read full answer

3. What is XPath?

XPath is an XML technology which is used to retrieve element from XML documents. Since XML documents are structured, XPath expression can be used to locate and retrieve elements, attributes or value from XML files.

Read full answer

4. How to select elements in XPATH based on attribute and element value?

John 32 Adam 36 In this example, to extract the age of employee Adam, the XPATH will be /employees/employee[name/text()='Adam']/age. The text() function...

Read full answer

5. What is XSLT?

XSLT is a popular XML technology to transform one XML file to other XML, HTML or any other format. XSLT language specifies its own syntax, functions, and operator to transform XML documents. Usually, transformation is done by XSLT Engine which reads instruction written using XSLT syntax in XML st...

Read full answer

6. Difference between DOM and SAX XML Parser in Java.

DOM parser loads entire XML document in memory while SAX only loads the part of the XML file in memory. DOM parser is faster than SAX because it accesses complete XML document in memory. SAX parser is suitable for large XML files than DOM Parser because it doesn't require much memory. DOM parser ...

Read full answer

7. What is XML namespace?

XML namespace is similar to package in Java that provides a way to avoid conflict between two xml tags of same name but different sources. XML namespace is defined using xmlns attribute at top of the XML document and has following syntax xmlns:prefix=’URI’. That prefix is used along with actual t...

Read full answer

8. What is XML data Binding in Java?

XML binding in Java refers to creating Java classes and object from XML documents and then modifying XML documents using Java.JAXB ,a Java API for XML binding provides convenient way to bind XML documents with Java objects.

Read full answer

9. Can you create a XML document using SAX parser?

Not recommended. Use SAX parser to parse or edit a XML document.It is better to use StAX parser for creating XML documents rather than using SAX parser.

Read full answer

10. What is SAX parser?

SAX stands for Simple API for XML . SAX Parser is an event-based parser for xml documents.

Read full answer

11. Difference between JAXB and DOM/SAX Parsers,

The Java DOM and SAX parsing APIs are lower-level APIs to parse XML documents, while JAXB is a higher-level API for converting XML elements and attributes to a Java object hierarchy (and vice versa). Implementations of JAXB will use a DOM or SAX parser behind the scenes to do the actual parsing o...

Read full answer

12. How do I validate an XML file against XSD file?

The Java runtime library supports validation which is backed by Apache Xerces parser. import java.io.File ; import java.io.IOException ; import java.net.MalformedURLException ; import java.net.URL ; import javax.xml.XMLConstants ; import javax.xml.transform.Source ; import javax.xml.transform.str...

Read full answer

13. Explain about XEE/XXE XML security Attacks.

XML Entity Expansion (XEE) also known as XML Expansion/XML Bomb, is an attack that consumes unsuspected vast memory resources. Usually attacker leverages a feature of XML whereby entity references can reference another entity. In DTD/XML External Entity (XXE) attacks, the victim is made to disclo...

Read full answer

14. How do you prevent Injection attacks?

Defending against SQL Injection-JDBC Prepared statements: The Java platform includes a defensive measure to protect yourself against the SQL injection attacks: JDBC prepared statements. JDBC prepared statements to work by precomputing the SQL query into a binary database proprietary format. Prior...

Read full answer

«
»

Comments & Discussions