XMLWriter is not working

Hi there,
I have to explain a lot, because I don't know why my scripts don't work.
My Initialize Script:

// Import the class we'll need.
import com.screenscraper.xml.XmlWriter;
import java.util.*;
import java.text.*;

DateFormat df1 = DateFormat.getDateInstance(DateFormat.SHORT);
Date now = new Date();
String s1 = df1.format(now);

XmlWriter xmlWriter = new XmlWriter("C:\\Users\\Basti\\Documents\\Scrapes\\soul\\" + s1 + ".xml",
                                                                                                                                                "soul");

session.setVariable( "XML_WRITER", xmlWriter );
session.setVariable("PAGE_NUMBER", "1");

I have a scrapableFile, that scrapes a details page. Before starting to scrape details page I run this script "XMLWriteProductTag":
xmlWriter = session.getVariable("XML_WRITER");

ProductElement = xmlWriter.addElement("Product");

session.setVariable("PRODUCT_ELEMENT", ProductElement);

Then I have got 11 Extractor Patterns for this details page.
Each Extractor pattern starts a script, so that the scraped information are added to XML after pattern is applied.
Example:
Identifier: ProductTitleExtractor Sequence:1
pattern text:

<div class="product-info">
<h1>~@ProductTitle@~</h1>

Script is started after pattern is applied: XMLWriteProductTitle:
xmlWriter = session.getVariable("XML_WRITER");
ProductElement = session.getVariable("PRODUCT_ELEMENT");

xmlWriter.addElement(ProductElement, "Title", session.getVariable("ProductTitle");

session.setVariable("PRODUCT_ELEMENT", ProductElement);

My other scripts look all the same, except the different variable identifiers.
But Debugger writes for every XMLWriterScript:
An error occurred while processing the script: XMLWriteProductTitle
The error message was: class bsh.ParseException (line 4): ( ProductElement , \"Title\" , session . getVariable ( \"ProductTitle\" ) ;-- Encountered "( ProductElement , \"Title\" , session . getVariable ( \"ProductTitle\" ) ;" at line 4, column 21.

I think there is a problem with setvariable and getVariable. In other testings i also had the problem, that saved XMLNodes could not be received in other scripts via getVariable()...

Can anyone tell me what's wrong with my scripts?

Best regards
Sebastian

---

---

Sebastian, You should add one

Sebastian,

You should add one more closing parenthesis to the end of this line.

xmlWriter.addElement(ProductElement, "Title", session.getVariable("ProductTitle");

should be...

xmlWriter.addElement(ProductElement, "Title", session.getVariable("ProductTitle"));

-Scott

Ah, thanks! But now I have

Ah, thanks!
But now I have got an other problem I had before:
In DetailsScrapeFile I have 11 Extractor Patterns. ExtractorPattern 10 extracts the sizes:
Identifier: ProductSizeExtractor Sequence:10
PatternText:
,"label":"US ~@ProductSize@~"
BeforePatternIsApplied: XMLWriteSizeTag
After Each Pattern Match: XMLWriteSizes

The Scripts:
XMLWriteSizeTag:

xmlWriter = session.getVariable("XML_WRITER");
ProductElement = session.getVariable("PRODUCT_ELEMENT");

SizeElement = xmlWriter.addElement(ProductElement, "AvailableSizes");

session.setVariable("SIZE_ELEMENT", SizeElement);

XMLWriteSizes:
xmlWriter = session.getVariable("XML_WRITER");
SizeElement = session.getVariable("SIZE_ELEMENT");

xmlWriter.addElement(SizeElement, "Size", session.getVariable("ProductSize"));

session.setVariable("SIZE_ELEMENT", SizeElement);

This one works so far....Now to the problem. I have got nearly the same scripts to extract image links:
Identifier: ImageExtractor Sequence:11
Patterntext:

<li><a href="~@ProductImageLink@~" onclick="$('image').src = this.href; return false;"><img src="~@ProductThumbnailLink@~" alt="" title="" /></a></li>

Before pattern is applied: XMLWriteImagetag
After each pattern match: XMLWriteImages

Script WriteImageTag:

xmlWriter = session.getVariable("XML_WRITER");
ProductElement = session.getVariable("PRODUCT_ELEMENT");

ImageElement = xmlWriter.addElement(ProductElement, "AdditionalImages");
ThumbnailElement = xmlWriter.addElement(ProductElement, "AdditionalThumbnails");

session.setVariable("IMAGE_ELEMENT", ImageElement);
session.setVariable("THUMBNAIL_ELEMENT", ThumbnailElement);

Script XMLWriteImages:

xmlWriter = session.getVariable("XML_WRITER");
ImageElement = session.getVariable("IMAGE_ELEMENT");
ThumbnailElement = session.getVariable("THUMBNAIL_ELEMENT");

xmlWriter.addElement(ImageElement, "Image", session.getVariable("ProductImageLink"));
xmlWriter.addElement(ThumbnailElement, "Thumbnail", session.getVariable("ProductThumbnailLink"));

session.setVariable("IMAGE_ELEMENT", ImageElement);
session.setVariable("THUMBNAIL_ELEMENT", ThumbnailElement);

ErrorMessages:
First call of XMLWriteImages:

Processing script: "XMLWriteImages"
An error occurred while processing the script: XMLWriteImages
The error message was: Exception (line 5): The parent element could not be found.-- Method Invocation xmlWriter.addElement

Every fallowing call of XMLWriteImages:
Processing script: "XMLWriteImages"
An error occurred while processing the script: XMLWriteImages
The error message was: IllegalAddException (line 5): The node "org.dom4j.tree.DefaultElement@90d7a [Element: <Image attributes: []/>]" could not be added to the branch "null" because: Cannot add another element to this Document as it already has a root element of: Image-- Method Invocation xmlWriter.addElement

Looks like ImageElement is not received correctly - but where is the problem, I thought i typed something wrong but it looks okay...

Best regards
Sebastian

No one with an idea?!

No one with an idea?!

Sebastian, Can you send me

Sebastian,

Can you send me your scraping session?

scottw [at] screen-scraper

-Scott

?! Where do I find the SSS?!

?! Where do I find the SSS?! We run ScreenScraper with Windows 7.

Sebaatian, Click the Export

Sebaatian,

Click the Export button under the main tab of your scraping session.

-Scott