• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DOM Parser

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Evry Example I have tried to validate a xml file to a dtd are based on that the user want to parse a file. What if i want to parse and xmldocument from that hasnt been written to the hd yet? I have methods for create a DOM-object and a method for writing it to a file. Im trying to use this code from the faq to parse my to-be-xml-file but i cant get it to work could anyone help me or point me to the right direction.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the XML forum...
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

parser.parse("data.xml"); // <--- Here i want to parse a doc, not file

Could you elaborate on this (if "doc" means org.w3c.dom.Document, it is already parsed...)?
For example, do you want to do
- parse("<?xml version='1.0'?><root><foo/><bar>...</bar></root>");
- parse(java.io.InputStream)
- something else?
 
Je Th
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want the source to be non-physic-file. I tried do type, parser.parse(MyDocument) where myDocument is the result of The scenario is that i want to validate a xmldoc to a DTD before i write it down in a file. Accrding to my resources the parse-method only accepts, File, URL resource, InpuStream & String data. So here is the deal really basic.
1. Load xml-flie from hd
2. Add more info to it
3. Validate old info + new info with a dtd
4. If sucessfull then write it down to a file on the hd.
Im done with all taks accept number 3. Validating the new document against a DTD.
Thanks for your time..
[ February 18, 2004: Message edited by: Je Th ]
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could combine this and this to produce an in-memory XML file including a DOCTYPE declaration, and then parse it like this.
It's a bit ugly, but should work.
 
I can't beleive you just said that. Now I need to calm down with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic