├── README.md └── xns2bind.py /README.md: -------------------------------------------------------------------------------- 1 | # xns2bind 2 | cloudxns export xml format to bind text format 3 | 4 | ## Usage 5 | 6 | ``` 7 | python3 xns2bind.py example.com.xml>example.com.txt 8 | ``` 9 | -------------------------------------------------------------------------------- /xns2bind.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python3 2 | 3 | import xml.etree.ElementTree as x 4 | 5 | 6 | def parse(file): 7 | 8 | name = file[:-3] 9 | 10 | tree = x.parse(file) 11 | root = tree.getroot() 12 | 13 | for child in root: 14 | if child.tag == 'rdata': 15 | sub = child[0].text + '.' 16 | rr_pref = child[4].text + '\t' 17 | 18 | if sub == '@.': 19 | sub = '' 20 | 21 | if rr_pref == 'N/A\t': 22 | rr_pref = '' 23 | 24 | print(sub + name + '\t' + child[5].text + '\tIN\t' + child[1].text + '\t' + rr_pref + child[3].text) 25 | 26 | 27 | if __name__ == "__main__": 28 | import sys 29 | parse("".join(sys.argv[1:])) 30 | --------------------------------------------------------------------------------