[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

DTD Reference from a DOMDocument

Posted on 2001-07-05
12
Medium Priority
?
653 Views
Last Modified: 2013-11-19
Here's one for you MSXML gurus.

I am creating an XML file using the DOMDocument object in VB, building nodes, but I can't figure out how to reference a DTD so that MyXMLDOMDocument.xml gives me back the <!DOCTYPE> node.   Anyone know how to
1.) Reference a DTD from the DOM
2.) Create a node that references the DTD from the DOM

Thanks all!
0
Comment
Question by:hvest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 2

Expert Comment

by:Lunchy
ID: 6256601
You posted this question twice.  Just to let you know I deleted the duplicate.

Lunchy
Community Support Moderator
0
 
LVL 5

Expert Comment

by:mattyk
ID: 6256715
Have you taken a look at the doctype property?  So for a sample xml like:

<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

the following code would give me note:

Dim objXML As New MSXML2.DOMDocument
objXML.Load ("E:\ee.xml")
debug.print(objXML.doctype.basename)
debug.print(objXML.doctype.xml)

-matty


0
 

Author Comment

by:hvest
ID: 6256836
Unfortunately, I don't have an xml file to load...I am actually building the XML on the fly using the XMLDOM and SQL data.  Thus I need to reference the DTD in the DOM so that MyDOMDocument.xml would yield:

<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<blah></blah>

I can do everything but the <!Doctype> node.

Basically I either need to set the doctype property of my DOMDocument (but doctype is read-only), or reference an external DTD from inside of my DOMDocument
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 5

Expert Comment

by:mattyk
ID: 6257225
Well I came across this:


which hints that the only way to accomplish this is to take your current xml , convert it to a string, add the <!Doctype> node and then reload the string back into the DOMDocument object.

http://www.vbxml.com/xml/articles/dom_xml_prog/default-19.asp?printerversion=true

-matty
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6257298
Why not, when you first create the DOM create it by adding a string... then you can append the desired nodes

Dim objXML As New MSXML2.DOMDocument

strTemp = "<?xml version='1.0'?><!DOCTYPE note SYSTEM 'note.dtd'>"


objXML.xml = strTemp
0
 

Author Comment

by:hvest
ID: 6257306
I wonder if there is any other way?  I haven't been able to find one yet...
0
 

Author Comment

by:hvest
ID: 6257315
That's a good suggestion Dave, but .xml is a read-only property
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6257329
It's been a couple of months since I've worked with it, just found your question... I'll see what I can come up with...
0
 
LVL 8

Accepted Solution

by:
Dave_Greene earned 1200 total points
ID: 6257465
Ok, here it is...  Another unfortunate limitation of XML & DTDs.  As far as accomplishing what you want in code, you will need to create a text file programmatically with your version / DTD info...

<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">

Then you will need to load this file into your DOM

objDOM.load "C:\Temp\temp.xml"

Then append your nodes as needed.

There is no easy way around this one.

It would be nice if it worked like Matty and I initially thought (Build the string and pop it into the DOM), but no beans.

Hope this helps!

-Dave
0
 

Author Comment

by:hvest
ID: 6257517
Thanks Dave!  Looks like I just got the short end of the stick on this problem...gonna have to go with the work-around
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6257558
Just one last note,

When using an internal DTD you do not need to define SYSTEM OR PUBLIC  ...  or an external file name...

Just

<!DOCTYPE note>

Cheers
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6257563
And of course...

Whatever DTD elements

<!DOCTYPE note[
    <!-- this is where the internal DTD subset is located. -->
  ]>
  <note>

Have a good one!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question