Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
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
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
Beginning Java
DOM doc is not adding a ProcessingInstruction
Dieter Stryker
Greenhorn
Posts: 11
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What am I doing wrong here that the ProcessingInstruction is not being added to the xmlDoc. All of my Elements are added with no issues...
public class XMLBuilder { public static final File outputFile = new File("C:\\Test.xml"); private Document xmlDoc; /** * @return - XML object to main() to be written to flat file */ void buildScoresXML(TreeMap teamMap) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = factory.newDocumentBuilder(); xmlDoc = builder.newDocument(); } catch(ParserConfigurationException pCE) { pCE.printStackTrace(); } FileWriter fstream = new FileWriter(outputFile); BufferedWriter out = new BufferedWriter(fstream); String cssURL = "\"CSS URL WILL BE HERE\""; // create root element Element rootElement = xmlDoc.createElement("lacrosse"); //has children xmlDoc.appendChild(rootElement); // add processing instruction for CSS file ProcessingInstruction pi = xmlDoc.createProcessingInstruction("xml-stylesheet", "test"); xmlDoc.appendChild(pi);
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Converting JDBC Statements into XML document using SAX or DOM
Appending data to existing XML file
Adding an xml-stylesheet Processing Instruction to a document
write to f file
Writing Strings in File
More...