# How to use parseXML method - class XML

**URL:** <https://forum.kirupa.com/t/how-to-use-parsexml-method-class-xml/296488>\
**Category:** flash\
**Created:** [September 15, 2009, 4:38pm UTC](https://forum.kirupa.com/t/how-to-use-parsexml-method-class-xml/296488 "2009-09-15T16:38:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mihaispr](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@mihaispr](https://forum.kirupa.com/u/mihaispr)\
**Post date:** [September 15, 2009, 4:38pm UTC](https://forum.kirupa.com/t/how-to-use-parsexml-method-class-xml/296488/1 "2009-09-15T16:38:09Z")

</div>

How can I create and parse an xml file in Actionscript 2 using parsexml method?

```auto

The following example creates and parses an XML packet: 
  //The following example creates and parses an XML packet:

var xml_str =
"<state name="California">
<city>San Francisco</city></state>"

// Defining the XML source within the XML constructor:
var my1_xml = new XML(xml_str);
trace(my1_xml.firstChild.attributes.name); // output: California

// Defining the XML source using the XML.parseXML method:
var my2_xml = new XML();
my2_xml.parseXML(xml_str);
trace(my2_xml.firstChild.attributes.name); 
// output: California

```

The error I receive:

![](http://img81.imageshack.us/img81/5616/errors.png)

How can I modify my code in order to suppress errors?

Thanks in advance for your support!
