DOMFormatter Class Reference
Inheritance diagram for DOMFormatter:
Detailed Description
A class for pretty-printing and outputing documents.
Example usage:
// the object "xml" will hold a string representation of a document NSString *xml = [DOMFormatter stringFromNode:document]; // the document will be written to a file [DOMFormatter writeNode:document toFile:@"/tmp/document.xml"];
The output format can be set by tweaking an instance of DOMFormatOptions. See the documentation for that class for more information.
Public Member Functions |
|
| (void) | setFormatOptions: |
| (void) | setContextNode: |
| (NSString *) | string |
| (BOOL) | writeToFile: |
Static Public Member Functions |
|
| (DOMFormatter *) | formatter |
| (NSString *) | stringFromNode: |
| (NSString *) | stringFromNode:formatOptions: |
| (BOOL) | writeNode:toFile: |
| (BOOL) | writeNode:toFile:formatOptions: |
Protected Attributes |
|
| DOMFormatOptions * | formatOptions |
| id< DOMNode > | contextNode |
Member Function Documentation
|
|
Returns a new formatter. |
|
|
Sets the context document. It is this document that will be formatted and outputed |
|
|
Sets a new options object as the options used. |
|
|
Creates a string representation of the document and returns it. The document will be formatted according to the default format options, or alternative format options, if applicable. Will replace &, <, >, ", and ' with the escaped versions. No XML prolog will be added to the string, even if that is set in the options. The prolog is however added by writeToFile:. It's not clear whether or not this is the expected behaviour, from reading the XML spec. |
|
|
||||||||||||
|
Equivalent to:
DOMFormatter *formatter = [DOMFormatter formatter]; [formatter setContextNode:node]; [formatter setOptions:[DOMFormatOptions formatOptions]]; NSString *result = [formatter string]; |
|
||||||||||||
|
||||||||||||||||
|
Equivalent to:
DOMFormatter *formatter = [DOMFormatter formatter]; [formatter setContextNode:node]; [formatter setOptions:[DOMFormatOptions formatOptions]]; [formatter writeToFile:@"..."]; |
|
|
Writes the results of string to a file at the specified path. Currently, the file will be written using UTF-8 encoding. In the future there will be a setting to change this. If the options are set to include a prolog, it will be added and the encoding will be specified as UTF-8. |
Member Data Documentation
|
|
|
|
|
|