# LightXML question

**URL:** https://discourse.julialang.org/t/lightxml-question/6352
**Category:** General Usage
**Created:** [October 9, 2017, 4:53pm UTC](https://discourse.julialang.org/t/lightxml-question/6352 "2017-10-09T16:53:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Frank\_Applin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frank_applin/32/1654_2.png) [@Frank\_Applin](https://discourse.julialang.org/u/Frank_Applin)
#### Post date: [October 9, 2017, 4:53pm UTC](https://discourse.julialang.org/t/lightxml-question/6352/1 "2017-10-09T16:53:16Z")

</div>

I’m reading an XML file that looks like this:

```julia
<machine_information>
	<machine name="Raspberry Pi" node="julia-user@NODE-RPI3" julia-bin="/home/julia-user/julia-0.6.0/bin/">
		<pins category="GPIO">
			<!--left pins (left) -->
			<PIN03>2</PIN03>
			<PIN05>3</PIN05>
			<PIN07>4</PIN07>
			<PIN11>17</PIN11>
			<PIN13>27</PIN13>
			<PIN15>22</PIN15>
			<PIN19>10</PIN19>
			<PIN21>9</PIN21>
			<PIN23>11</PIN23>
			<!--left pins (right) -->
			<PIN29>5</PIN29>
			<PIN31>6</PIN31>
			<PIN33>13</PIN33>
			<PIN35>19</PIN35>
			<PIN37>26</PIN37>
			<!--right pins (left) -->
			<PIN08>14</PIN08>
			<PIN10>15</PIN10>
			<PIN12>18</PIN12>
			<PIN16>23</PIN16>
			<PIN18>24</PIN18>
			<PIN22>25</PIN22>
			<PIN24>8</PIN24>
			<PIN26>7</PIN26>
			<!--right pins (right) -->
			<PIN32>12</PIN32>
			<PIN36>16</PIN36>
			<PIN38>20</PIN38>
			<PIN40>21</PIN40>
		</pins>
        </machine>
</machine_information>

```

I use the following code to get at different aspects:

```julia
using LightXML
xdoc = parse_file("RPI3.conf")

# get the root element
xroot = root(xdoc) # an instance of XMLElement
# print its name
println(name(xroot)) # this should print: machine_information

machine = get_elements_by_tagname(xroot, "machine")
name = attribute(machine[1], "name")
node = attribute(machine[1], "node")
bindir = attribute(machine[1], "julia-bin")
pins = find_element(machine[1], "pins")
pin = collect(child_elements(pins))

```

So, the last line I am trying to access individual pins in a collection:

```julia
julia> pin
26-element Array{Any,1}:
 <PIN03>2</PIN03> 
 <PIN05>3</PIN05> 
 <PIN07>4</PIN07> 
 <PIN11>17</PIN11>
 <PIN13>27</PIN13>
 <PIN15>22</PIN15>
 <PIN19>10</PIN19>
 <PIN21>9</PIN21> 
 <PIN23>11</PIN23>
 <PIN29>5</PIN29> 
 ⋮                
 <PIN16>23</PIN16>
 <PIN18>24</PIN18>
 <PIN22>25</PIN22>
 <PIN24>8</PIN24> 
 <PIN26>7</PIN26> 
 <PIN32>12</PIN32>
 <PIN36>16</PIN36>
 <PIN38>20</PIN38>
 <PIN40>21</PIN40>

```

If I do content(pin[1]) I get the value “2” - good. content(pin[2]) I get the value “3”. But, I want to get the name of the node, I get an error.

```julia
julia> name(pin[2])
ERROR: MethodError: objects of type String are not callable

```

Am I accessing this correctly? I would like to be able to loop through the pin collection and get the name and the value.

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [October 9, 2017, 5:06pm UTC](https://discourse.julialang.org/t/lightxml-question/6352/2 "2017-10-09T17:06:09Z")

</div>

You’ve assigned `name` a value:

```julia
name = attribute(machine[1], "name")

```

which is masking the `name()` function that you’re trying to call. Either change the name of your variable to something else or call `LightXML.name()`.

---

<div class="post-metadata">

### Author: ![Frank\_Applin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frank_applin/32/1654_2.png) [@Frank\_Applin](https://discourse.julialang.org/u/Frank_Applin)
#### Post date: [October 9, 2017, 5:07pm UTC](https://discourse.julialang.org/t/lightxml-question/6352/3 "2017-10-09T17:07:17Z")

</div>

Thanks. That was a duh! moment.
