Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

xml ingore whitespace

 
jim li
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i am using :

DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();

docFactory.setIgnoringElementContentWhitespace(true);
docFactory.setFeature("http://apache.org/xml/features/dom/include-ignorable-whitespace",
false);
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

Document doc = docBuilder.parse(xsltFile);

but it does not ingore the white space, i do not want to remove all space manually , can anyone give me a solution
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whitespace is only "ignorable" if you have a schema which describes the document. (Your code doesn't validate, so you don't have a schema.) Otherwise there is no way for the parser to tell which whitespace you are not interested in.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic