Define Blast Xml Parser By Dtd
1
0
Entering edit mode
10.5 years ago
pld 5.1k

I have seen many examples of using a DTD to validate XML documents, but I was wondering if they could be used to dynamically define a document at runtime. Specifically, I was wondering if a DTD and a list of 'target' elements could be used to collect values (under those elements) from a document.

blast python xml • 1.5k views
ADD COMMENT
0
Entering edit mode

not clear: can you give us an example please.

ADD REPLY
1
Entering edit mode
10.5 years ago
Hamish ★ 3.2k

While the XML support in many programming languages and tools support generation of parser code from an XML DTD or an XML Schema), I am not sure that is really what you are looking for...

The case you describe sounds more like a case for using XPath to directly extract the specified elements, or XQuery to search an XML database to access the XML document(s). Since you will need to use XPath to unambiguously specify the elements you wish to extract from the document, it will likely make sense to start with the XPath support provided in the XML library you are using and work from there.

The w3schools tutorials may provide a helpful starting point:

As Pierre Lindenbaum and I have noted in other answers on BioStars, depending on exactly what you are trying to do, you may find it easiest to use an XSLT stylesheet (w3schools tutorial) to specify the specific data to be extracted from the XML document(s) and produce a more parser friendly output containing just the data you require, instead of working directly with the XML document. Obviously you could generate the XSLT stylesheet given the document schema and the specific elements required.

ADD COMMENT

Login before adding your answer.

Traffic: 1947 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6