Difference Between XMLDocument and XPathDocument
XMLDocument vs an XPathDocument
XMLDocument and XPathDocument are two namespaces that are used when dealing with XML files. These two are used when creating applications that need the ability to read or write data into XML files. The main difference between XMLDocument and XPathDocument is the approach. XMLDocument is an object-oriented approach. An object is created and linked to a specific file, and the object has the necessary procedures and functions for dealing with the said file. In contrast, XPathDocument is a data-oriented approach. It is simpler than XMLDocument but doesn’t have the advantage of flexibility offered by XMLDocument.
The biggest disadvantage of using XPathDocument is its lack of ability to modify the contents of the file. It is attached as read only, and there is no way to commit any changes. XMLDocument can change the content of the file. It can also add new nodes, delete existing ones, and even modify the attributes of the file. Another major disadvantage of XPathDocument is its inability to create new documents from scratch. So you need to make sure that the file is already in existence before attempting to access it via XPathDocument. XMLDocument doesn’t have this limitation, and it can create documents from scratch and then add content to it.
Despite the many disadvantages of using XPathDocument over XMLDocument, there are also areas where using it would be beneficial. The simplicity of XPathDocument gives it a bit of a speed advantage over XMLDocument. Because of this, XPathDocument is often preferred when reading from very large files. Loading these files using XMLDocument can take a long time and would offer no advantage if the only operation performed is read. For everything else or for general purpose applications, it is better to use XMLDocument as it is more flexible and provides more features. The performance cost is also less of an issue when dealing with small files and is very likely to go unnoticed for most applications.
Summary:
1.XMLDocument is an object-oriented model while XPathDocument is a data-oriented model.
2.XPathDocument only provides read access while XMLDocument provides read and write access.
3.XMLDocument allows the creation of a new XML document while XPathDocument doesn’t.
4.XPathDocument may be better for reading large documents over XMLDocument.
- Difference Between Sony Cybershot S Series and W Series - December 22, 2012
- Difference Between Samsung Galaxy S3 and iPhone 5 - December 21, 2012
- Difference Between Samsung Galaxy S2 (Galaxy S II) and Galaxy S 4G - December 20, 2012
Search DifferenceBetween.net :
Email This Post : If you like this article or our site. Please spread the word. Share it with your friends/family.