### Install xmindparser Source: https://github.com/tobyqin/xmindparser/blob/master/README.md Installs the xmindparser library using pip. This is the primary way to get the package for use in Python projects. ```shell pip install xmindparser ``` -------------------------------- ### Install xmindparser and Optional Dependencies Source: https://context7.com/tobyqin/xmindparser/llms.txt Installs the xmindparser library using pip. Optional dependencies for XML and YAML export can also be installed separately. ```bash pip install xmindparser # Optional dependencies for XML and YAML export pip install dicttoxml # Required for XML export pip install pyyaml # Required for YAML export ``` -------------------------------- ### Export XMind to XML File using xmind_to_xml Source: https://context7.com/tobyqin/xmindparser/llms.txt Illustrates converting an XMind file to an XML file using `xmind_to_xml`. This function requires the `dicttoxml` package to be installed. It handles potential `ImportError` if the dependency is missing. ```python from xmindparser import xmind_to_xml # Convert XMind to XML file (requires: pip install dicttoxml) try: output_file = xmind_to_xml('/path/to/mindmap.xmind') print(f'Generated: {output_file}') except ImportError as e: print('Install dicttoxml: pip install dicttoxml') ``` -------------------------------- ### Command Line Interface Source: https://context7.com/tobyqin/xmindparser/llms.txt Provides a command-line tool for quick conversions of XMind files to other formats without writing Python code. ```APIDOC ## Command Line Interface ### Description xmindparser provides a command-line tool for quick conversions without writing Python code. ### Usage Navigate to the directory containing your XMind files and use the `xmindparser` command followed by the input file and desired format flag. ### Examples **Convert to JSON:** ```bash xmindparser mindmap.xmind -json ``` Output: ``` Generated: /your/xmind/directory/mindmap.json ``` **Convert to Markdown:** ```bash xmindparser mindmap.xmind -md ``` Output: ``` Generated: /your/xmind/directory/mindmap.md ``` **Convert to XML:** ```bash xmindparser mindmap.xmind -xml ``` Output: ``` Generated: /your/xmind/directory/mindmap.xml ``` **Convert to YAML:** ```bash xmindparser mindmap.xmind -yaml ``` Output: ``` Generated: /your/xmind/directory/mindmap.yaml ``` ``` -------------------------------- ### Command Line Interface for xmindparser Conversions Source: https://context7.com/tobyqin/xmindparser/llms.txt Provides a command-line tool for converting XMind files to different formats without writing Python code. Users can specify the output format using flags like -json, -xml, -yaml, or -markdown. ```bash # Navigate to directory containing XMind files cd /your/xmind/directory # Convert to JSON xmindparser mindmap.xmind -json # Output: Generated: /your/xmind/directory/mindmap.json ``` -------------------------------- ### Command Line Parsing with xmindparser Source: https://github.com/tobyqin/xmindparser/blob/master/README.md Demonstrates how to use the xmindparser command-line interface to convert Xmind files to different formats like JSON, XML, YAML, and Markdown. Note that XML and YAML parsing may require additional dependencies. ```shell cd /your/xmind/dir xmindparser your.xmind -json xmindparser your.xmind -xml xmindparser your.xmind -yaml xmindparser your.xmind -markdown ``` -------------------------------- ### Configuration Options Source: https://context7.com/tobyqin/xmindparser/llms.txt Customize parsing behavior using the global configuration object, including settings for topic IDs, empty values, structure info, relationships, and logging. ```APIDOC ## Configuration Options ### Description xmindparser provides a configuration object to customize parsing behavior, including topic ID visibility, empty value handling, structure info, relationships, and logging settings. ### Accessing and Modifying Configuration Use the `config` dictionary and `apply_config()` function. ### Configuration Parameters - **`showTopicId`** (boolean) - Default: `False`. Show internal topic IDs in output. - **`hideEmptyValue`** (boolean) - Default: `True`. Hide empty values instead of showing them. - **`showStructure`** (boolean) - Default: `True`. Include sheet structure info. - **`showRelationship`** (boolean) - Default: `False`. Include relationship info for Zen/2026 files. - **`logName`** (string) - Custom name for the logger. - **`logLevel`** (logging level) - Set the logging level (e.g., `logging.DEBUG`). - **`logFormat`** (string) - Define the log message format. ### Request Example ```python import logging from xmindparser import xmind_to_dict, config, apply_config # Enable showing topic IDs config['showTopicId'] = True # Disable hiding empty values config['hideEmptyValue'] = False # Configure logging config['logName'] = 'my_xmind_parser' config['logLevel'] = logging.DEBUG config['logFormat'] = '%(asctime)s %(levelname)-8s: %(message)s' # Apply configuration changes, especially for logging apply_config() # Parse XMind file with the new configuration data = xmind_to_dict('/path/to/mindmap.xmind') ``` ### Response Example (with `showTopicId=True`) ```json { "id": "abc123", "title": "Sheet 1", "topic": { "id": "def456", "title": "Root Topic", ... } } ``` ### Response Example (with `showRelationship=True`) ```json { "title": "Sheet 1", "topic": {...}, "relationships": [ {"end1Id": "id1", "end2Id": "id2", "title": "relates to"} ] } ``` ``` -------------------------------- ### Configure xmindparser Logging and Options in Python Source: https://github.com/tobyqin/xmindparser/blob/master/README.md Demonstrates how to configure the xmindparser library in Python, including setting logging parameters (name, level, format) and modifying parsing options like `showTopicId`, `hideEmptyValue`, `showStructure`, and `showRelationship`. The `apply_config()` function is required for logging changes to take effect. ```python import logging from xmindparser import xmind_to_dict, config, apply_config # Modify config settings config['logName'] = 'your_log_name' config['logLevel'] = logging.DEBUG config['logFormat'] = '%(asctime)s %(levelname)-8s: %(message)s' config['showTopicId'] = True # internal id will be included, default = False config['hideEmptyValue'] = False # empty values will be hidden, default = True config['showStructure'] = False # include structure info for sheets, default = True config['showRelationship'] = True # include relationship info for Zen/2026 files, default = False # Apply the config changes (required for logging settings to take effect) apply_config() d = xmind_to_dict('/path/to/your/xmind') print(d) ``` -------------------------------- ### Configure xmindparser Parsing Behavior Source: https://context7.com/tobyqin/xmindparser/llms.txt Customize the parsing process using a global configuration object. Options include controlling the visibility of topic IDs, handling of empty values, inclusion of structure and relationship information, and setting up logging. Changes to logging settings require calling apply_config(). ```python import logging from xmindparser import xmind_to_dict, config, apply_config # Show internal topic IDs in output (default: False) config['showTopicId'] = True # Show empty values instead of hiding them (default: True = hide empty) config['hideEmptyValue'] = False # Include sheet structure info (default: True) config['showStructure'] = True # Include relationship info for Zen/2026 files (default: False) config['showRelationship'] = True # Configure logging config['logName'] = 'my_xmind_parser' config['logLevel'] = logging.DEBUG config['logFormat'] = '%(asctime)s %(levelname)-8s: %(message)s' # IMPORTANT: Apply config changes for logging settings to take effect apply_config() # Parse with new configuration data = xmind_to_dict('/path/to/mindmap.xmind') ``` -------------------------------- ### Tagging and Pushing a New Version Source: https://github.com/tobyqin/xmindparser/blob/master/DEVELOPER.md Commands to create a new version tag in Git and push it to the remote repository. This action triggers the GitHub Actions workflow to build and publish the package to PyPI. ```shell git tag v1.1.0 git push origin v1.1.0 ``` -------------------------------- ### Export XMind to YAML File using xmind_to_yaml Source: https://context7.com/tobyqin/xmindparser/llms.txt Demonstrates converting an XMind file to a YAML file with proper Unicode support using `xmind_to_yaml`. This function requires the `pyyaml` package and includes error handling for missing dependencies. ```python from xmindparser import xmind_to_yaml # Convert XMind to YAML file (requires: pip install pyyaml) try: output_file = xmind_to_yaml('/path/to/mindmap.xmind') print(f'Generated: {output_file}') except ImportError as e: print('Install pyyaml: pip install pyyaml') ``` -------------------------------- ### Export XMind to JSON File using xmind_to_json Source: https://context7.com/tobyqin/xmindparser/llms.txt Shows how to convert an XMind file into a formatted JSON file using the `xmind_to_json` function. The function returns the path to the newly created JSON file. ```python from xmindparser import xmind_to_json # Convert XMind to JSON file output_file = xmind_to_json('/path/to/mindmap.xmind') print(f'Generated: {output_file}') ``` -------------------------------- ### Export XMind to Various Formats using xmind_to_file Source: https://context7.com/tobyqin/xmindparser/llms.txt A versatile function to export XMind files into different formats including JSON, XML, YAML, and Markdown. It takes the input file path and the desired format type as string arguments. Error handling for unsupported formats and missing dependencies is included. ```python from xmindparser import xmind_to_file # Convert to different formats using a single function json_file = xmind_to_file('/path/to/mindmap.xmind', 'json') xml_file = xmind_to_file('/path/to/mindmap.xmind', 'xml') yaml_file = xmind_to_file('/path/to/mindmap.xmind', 'yaml') # or 'yml' md_file = xmind_to_file('/path/to/mindmap.xmind', 'markdown') # or 'md' # Useful for dynamic format selection def convert_xmind(input_file, format_type): try: output = xmind_to_file(input_file, format_type) return f'Successfully generated: {output}' except ValueError as e: return f'Unsupported format: {format_type}' except ImportError as e: return f'Missing dependency: {e}' print(convert_xmind('project.xmind', 'json')) ``` -------------------------------- ### Convert XMind to Markdown using xmind_to_markdown Source: https://context7.com/tobyqin/xmindparser/llms.txt Converts an XMind file into a hierarchical Markdown document. Topics are transformed into headings, notes into blockquotes, and links are preserved. The function returns the path to the generated Markdown file. ```python from xmindparser import xmind_to_markdown # Convert XMind to Markdown file output_file = xmind_to_markdown('/path/to/mindmap.xmind') print(f'Generated: {output_file}') ``` -------------------------------- ### Convert XMind to Structured Formats via CLI Source: https://context7.com/tobyqin/xmindparser/llms.txt Use the xmindparser CLI to convert a single .xmind file into XML, YAML, or Markdown formats. Note that XML and YAML conversions require additional dependencies like dicttoxml and pyyaml respectively. ```bash xmindparser mindmap.xmind -xml xmindparser mindmap.xmind -yaml xmindparser mindmap.xmind -markdown ``` -------------------------------- ### Batch Convert XMind Files to JSON Source: https://context7.com/tobyqin/xmindparser/llms.txt Automate the conversion of multiple .xmind files in a directory to JSON format using a bash loop. This is useful for processing large sets of mind maps in a single workflow. ```bash for file in *.xmind; do xmindparser "$file" -json done ``` -------------------------------- ### Export XMind to Markdown File Source: https://context7.com/tobyqin/xmindparser/llms.txt Converts an XMind file to a hierarchical Markdown document. Topics become headings, notes become blockquotes, and links are preserved. ```APIDOC ## xmind_to_markdown - Export XMind to Markdown File ### Description Converts an XMind file to a hierarchical Markdown document. Topics become headings, notes become blockquotes, and links are preserved. ### Method `xmind_to_markdown` ### Parameters - **input_file** (string) - Required - Path to the XMind file. ### Response - **output_file** (string) - Path to the generated Markdown file. ### Request Example ```python from xmindparser import xmind_to_markdown output_file = xmind_to_markdown('/path/to/mindmap.xmind') print(f'Generated: {output_file}') ``` ### Response Example ``` Generated: /path/to/mindmap.md ``` ### Generated Markdown Structure Example ```markdown # Sheet 1 ## Root Topic ### Child 1 [Link](http://test.com) ### Child 2 > Important note **Labels:** label1, label2 **Comments:** - **author**: Comment content ``` ``` -------------------------------- ### Convert Xmind to Markdown File in Python Source: https://github.com/tobyqin/xmindparser/blob/master/README.md Converts an Xmind file to a Markdown file using the `xmind_to_markdown` function. An alternative `xmind_to_file` function is also shown for generic file conversion. ```python from xmindparser import xmind_to_markdown # Convert xmind to markdown file output_file = xmind_to_markdown('/path/to/your/xmind') print(f'Generated: {output_file}') ``` ```python from xmindparser import xmind_to_file # Convert to markdown output_file = xmind_to_file('/path/to/your/xmind', 'markdown') print(f'Generated: {output_file}') ``` -------------------------------- ### Generic Format Export Source: https://context7.com/tobyqin/xmindparser/llms.txt A unified function to convert XMind files to any supported format (JSON, XML, YAML, Markdown) by specifying the format type as a string parameter. ```APIDOC ## xmind_to_file - Generic Format Export ### Description A unified function to convert XMind files to any supported format. Accepts format type as a string parameter. ### Method `xmind_to_file` ### Parameters - **input_file** (string) - Required - Path to the XMind file. - **format_type** (string) - Required - The desired output format (e.g., 'json', 'xml', 'yaml', 'markdown'). ### Response - **output_file** (string) - Path to the generated file in the specified format. ### Request Example ```python from xmindparser import xmind_to_file json_file = xmind_to_file('/path/to/mindmap.xmind', 'json') xml_file = xmind_to_file('/path/to/mindmap.xmind', 'xml') md_file = xmind_to_file('/path/to/mindmap.xmind', 'markdown') ``` ### Error Handling Example ```python from xmindparser import xmind_to_file def convert_xmind(input_file, format_type): try: output = xmind_to_file(input_file, format_type) return f'Successfully generated: {output}' except ValueError as e: return f'Unsupported format: {format_type}' except ImportError as e: return f'Missing dependency: {e}' print(convert_xmind('project.xmind', 'json')) ``` ``` -------------------------------- ### Detect XMind File Type using is_xmind_zen Source: https://context7.com/tobyqin/xmindparser/llms.txt Determines whether an XMind file is in the newer Zen/2026 format or the legacy XMind 8 format. This utility is useful for applying format-specific processing logic, such as enabling relationship parsing for Zen files or comment parsing for legacy files. ```python from xmindparser import is_xmind_zen, xmind_to_dict # Check file format before processing file_path = '/path/to/mindmap.xmind' if is_xmind_zen(file_path): print('This is an XMind Zen/2026 file (uses content.json internally)') else: print('This is an XMind 8 (legacy) file (uses content.xml internally)') # Useful for conditional processing def process_xmind(file_path): if is_xmind_zen(file_path): # Zen/2026 files support relationships and stickers # config['showRelationship'] = True # Assuming config is imported and available pass else: # Legacy files support comments pass return xmind_to_dict(file_path) ``` -------------------------------- ### Extract Built-in JSON Content from Xmind Zen Files Source: https://github.com/tobyqin/xmindparser/blob/master/README.md Provides a function `get_xmind_zen_builtin_json` to directly extract the internal JSON content from Xmind Zen files. This is useful for understanding the raw data structure. ```python from xmindparser import get_xmind_zen_builtin_json content_json = get_xmind_zen_builtin_json(xmind_zen_file) ``` -------------------------------- ### Parse Xmind to Dictionary in Python Source: https://github.com/tobyqin/xmindparser/blob/master/README.md Converts an Xmind file into a Python dictionary using the `xmind_to_dict` function. This is the core function for programmatic access to Xmind content. ```python from xmindparser import xmind_to_dict d = xmind_to_dict('/path/to/your/xmind') print(d) ``` -------------------------------- ### Detect XMind File Type Source: https://context7.com/tobyqin/xmindparser/llms.txt Utility function to determine if an XMind file is in the newer Zen/2026 format or the legacy XMind 8 format. ```APIDOC ## is_xmind_zen - Detect XMind File Type ### Description Utility function to determine if an XMind file is in the newer Zen/2026 format or the legacy XMind 8 format. ### Method `is_xmind_zen` ### Parameters - **file_path** (string) - Required - Path to the XMind file. ### Response - **boolean** - `True` if the file is XMind Zen/2026 format, `False` otherwise. ### Request Example ```python from xmindparser import is_xmind_zen, xmind_to_dict file_path = '/path/to/mindmap.xmind' if is_xmind_zen(file_path): print('This is an XMind Zen/2026 file') # Process Zen file features # ... else: print('This is an XMind 8 (legacy) file') # Process legacy file features # ... # Example of conditional processing def process_xmind(file_path): if is_xmind_zen(file_path): # Zen/2026 files support relationships and stickers # config['showRelationship'] = True # Example configuration pass else: # Legacy files support comments pass return xmind_to_dict(file_path) ``` ``` -------------------------------- ### Access Raw JSON Content (XMind Zen) Source: https://context7.com/tobyqin/xmindparser/llms.txt For XMind Zen/2026 files, this function extracts the raw internal JSON content directly from the .xmind archive without any transformation. ```APIDOC ## get_xmind_zen_builtin_json - Access Raw JSON Content ### Description For XMind Zen/2026 files, this function extracts the raw internal JSON content directly from the .xmind archive without any transformation. ### Method `get_xmind_zen_builtin_json` ### Parameters - **file_path** (string) - Required - Path to the XMind Zen/2026 file. ### Response - **raw_content** (list of dicts) - The parsed `content.json` from inside the .xmind zip archive, representing the unprocessed XMind internal format. ### Request Example ```python from xmindparser import get_xmind_zen_builtin_json try: raw_content = get_xmind_zen_builtin_json('/path/to/zen_mindmap.xmind') for sheet in raw_content: print(f"Sheet ID: {sheet.get('id')}") print(f"Title: {sheet.get('title')}") root = sheet.get('rootTopic', {{}}) print(f"Root topic: {root.get('title')}") except AssertionError: print('Not an XMind Zen/2026 file!') ``` ### Use Cases - Debugging XMind internal structure. - Accessing properties not exposed by `xmind_to_dict`. - Building custom parsers. ``` -------------------------------- ### Parse Xmind Zen/2026 to Dictionary in Python Source: https://github.com/tobyqin/xmindparser/blob/master/README.md Parses Xmind Zen or 2026 files into a Python dictionary. This function is specifically designed to handle the internal JSON structure of these newer Xmind versions. ```python from xmindparser import xmind_to_dict d = xmind_to_dict('/path/to/your/xmind_zen_file') print(d) ``` -------------------------------- ### Access Raw JSON Content from XMind Zen Files Source: https://context7.com/tobyqin/xmindparser/llms.txt Extracts the raw, unprocessed internal JSON content from XMind Zen/2026 files. This function is useful for debugging, accessing specific internal properties not exposed by standard parsing, or building custom parsing logic. It returns the parsed content.json from within the .xmind archive. ```python from xmindparser import get_xmind_zen_builtin_json # Get raw internal JSON from XMind Zen/2026 file try: raw_content = get_xmind_zen_builtin_json('/path/to/zen_mindmap.xmind') # raw_content is the parsed content.json from inside the .xmind zip # This is the unprocessed XMind internal format for sheet in raw_content: print(f"Sheet ID: {sheet.get('id')}") print(f"Title: {sheet.get('title')}") root = sheet.get('rootTopic', {}) print(f"Root topic: {root.get('title')}") except AssertionError: print('Not an XMind Zen/2026 file!') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.