react-native-turboxml
Version:
A high-performance native XML parser for React Native built with Kotlin and Objective-C using TurboModules and the New Architecture.
137 lines (102 loc) β’ 3.17 kB
Markdown
<p align="center">
<img src="./assets/logo.png" alt="TurboXML β React Native XML Parser Logo" width="280" />
</p>
<h1 align="center">π TurboXML β Fast XML Parser for React Native (TurboModules)</h1>
<p align="center">
A blazing-fast, Android-native XML parser built for React Nativeβs New Architecture using Kotlin, JSI, and TurboModules.
<br />
<strong>4Γ faster</strong> than <code>react-native-xml2js</code> in parsing large XML files.
</p>
## β‘ Features
- β
4Γ faster than `react-native-xml2js`
- β
Native multithreaded XML parsing on Android
- β
Powered by TurboModules + JSI (New Architecture support)
- β
Lightweight and fully typed (TypeScript ready)
- β
Designed for offline, map-heavy, or config-driven React Native apps
## π¦ Installation
```bash
npm install react-native-turboxml
# or
yarn add react-native-turboxml
```
Make sure **New Architecture** is enabled:
```bash
cd ios && RCT_NEW_ARCH_ENABLED=1 pod install && cd ..
```
> β οΈ Currently supports **Android only**. iOS support planned for future releases.
## π§ͺ Usage Example
```tsx
import { useEffect, useState } from 'react';
import { Text, View, StyleSheet } from 'react-native';
import { parseXml } from 'react-native-turboxml';
export default function App() {
const [parsedResult, setParsedResult] = useState<string | null>(null);
useEffect(() => {
const xml = `
<config>
<title>TurboXML</title>
<enabled>true</enabled>
<version>1.0</version>
</config>
`;
parseXml(xml)
.then((result) => {
setParsedResult(JSON.stringify(result, null, 2));
})
.catch((error) => {
setParsedResult(\`Error: \${error.message}\`);
});
}, []);
return (
<View style={styles.container}>
<Text style={styles.title}>Parsed XML:</Text>
<Text style={styles.output}>{parsedResult}</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 24,
justifyContent: 'center',
},
title: {
fontWeight: 'bold',
marginBottom: 8,
},
output: {
fontFamily: 'monospace',
},
});
```
## β
Example Output
```json
{
"config": {
"title": ["TurboXML"],
"enabled": ["true"],
"version": ["1.0"]
}
}
```
## π Why TurboXML?
If your app needs to parse large XML files β such as **offline maps**, **configuration files**, or **external data feeds** β `react-native-turboxml` offers a significant speed improvement over JavaScript-based parsers by leveraging native code, multithreading, and the React Native New Architecture (TurboModules + JSI).
## π Requirements
- React Native 0.71+ with **New Architecture enabled**
- Android 5+ (iOS support coming)
- TurboModule + JSI support (enabled by default in modern RN projects)
## π API Reference
```ts
function parseXml(xml: string): Promise<Record<string, any>>;
```
### π Contribute or Sponsor
Got feature ideas or want to help bring iOS support? PRs welcome!
If this module helps your app or workflow, consider starring the repo or [reaching out](https://github.com/MikeOuroumis).