Dmitry
Dmitry

Reputation: 694

SOAPUI: parsing xml FILE

I have an issue with parsing XML file(not response. I need parsing from file)

So, I have file TRY.xml like

<!DOCTYPE request SYSTEM "URIWHEREDTD.dtd">
<request>
   <tag1>1</tag1>
   <tag2>2</tag2>
</request>
<request>
   <tag1>1</tag1>
   <tag2>3</tag2>
</request>

File can be really huge, It can be received NOT via soapui etc. So, I need to parse from file.

When I try

def inputFile = new XmlParser().parse("c:/TRY.xml")

it just returned

org.xml.sax.SAXParseException,...
Comment must start with "  error

I added that " to xml file, but new error is:

Content is not allowed in prolog

So, this is a problem...

Can anyone be so kind, and gimme solution for this error, or some other way to parse xml file?

E.g, in my "example" file I want to parse for elements(and get their values) for tag1[1], tag1[2] etc.

Upvotes: 0

Views: 965

Answers (1)

albciff
albciff

Reputation: 18517

A valid xml file must have only a one root node, in your XML you have two root nodes <request>, you've to change your XML file to something like:

<!DOCTYPE request SYSTEM "URIWHEREDTD.dtd">
<root>
    <request>
       <tag1>1</tag1>
       <tag2>2</tag2>
    </request>
    <request>
       <tag1>1</tag1>
       <tag2>3</tag2>
    </request>
</root>

Additionally your error probably comes from the dtd schema, which is not shown in your question.

Hope this helps,

Upvotes: 1

Related Questions