-1

XML::Simple documentation says to initiate the data structure with an XML file, using XMLin('[FILENAME]') ... but I have an in-memory string.

Can I use it directly, or do I need to save it to the filesystem and then load it into XMLin?

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
mblackwell8
  • 3,065
  • 3
  • 21
  • 23

2 Answers2

5

You seem to have missed in said documentation the following information:

XMLin() accepts an optional XML specifier followed by zero or more 'name => value' option pairs. The XML specifier can be one of the following:

...

A string of XML

A string containing XML (recognised by the presence of '<' and '>' characters) will be parsed directly. eg:

  $ref = XMLin('<opt username="bob" password="flurp" />');
Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
1

It also says

my $ref = $xs->XMLin([<xml file or string>] [, <options>]);
zakovyrya
  • 9,579
  • 6
  • 39
  • 28