# How to code XML processing using Processing(Python mode)

**URL:** https://discourse.processing.org/t/how-to-code-xml-processing-using-processing-python-mode/12484
**Category:** Processing.py
**Created:** [July 3, 2019, 5:12pm UTC](https://discourse.processing.org/t/how-to-code-xml-processing-using-processing-python-mode/12484 "2019-07-03T17:12:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![proc8888](https://avatars.discourse-cdn.com/v4/letter/p/f19dbf/32.png) [@proc8888](https://discourse.processing.org/u/proc8888)
#### Post date: [July 3, 2019, 5:12pm UTC](https://discourse.processing.org/t/how-to-code-xml-processing-using-processing-python-mode/12484/1 "2019-07-03T17:12:15Z")

</div>

Hello, I am new to posting in this forum and currently learning Processing (Python mode). I would like to convert the following code from Processing(tested and working) to Python mode but not sure what’s the syntax. Checked Processing.py reference but cannot find commands there for XML processing.  
I would like to convert the following, much thanks for your help/tips. Regards, Paul

XML xml;  
void setup() {  
xml = loadXML(“test02.xml”);  
XML[] children = xml.getChildren(“Record”);

for (int i = 0; i \< children.length; i++) {  
String v\_rectype = children[i].getString(“type”);  
float v\_value = children[i].getFloat(“value”);  
println(v\_rectype + ", " + v\_value);  
}  
}

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [July 3, 2019, 6:26pm UTC](https://discourse.processing.org/t/how-to-code-xml-processing-using-processing-python-mode/12484/2 "2019-07-03T18:26:05Z")

</div>

[Processing.org/reference/loadXML\_.html](http://Processing.org/reference/loadXML_.html)

```auto
FILENAME = 'test02.xml'
RECORD, TYPE, VALUE = 'Record', 'type', 'value'

def setup():
    global xml
    xml = loadXML(FILENAME)
    printXMLChildren(xml)
    exit()

def printXMLChildren(xml):
    for child in xml.getChildren(RECORD):
        type = child.getString(TYPE)
        value = child.getFloat(VALUE)
        print type, value

```

## “test02.xml”:

```auto
<records>
  <Record type="some stuff" value="74.83" />
  <Record type="another stuff" value="-1e-3" />
</records>

```

---

<div class="post-metadata">

### Author: ![proc8888](https://avatars.discourse-cdn.com/v4/letter/p/f19dbf/32.png) [@proc8888](https://discourse.processing.org/u/proc8888)
#### Post date: [July 4, 2019, 8:39am UTC](https://discourse.processing.org/t/how-to-code-xml-processing-using-processing-python-mode/12484/4 "2019-07-04T08:39:54Z")

</div>

Much thanks GoToLoop!
