Skip to Content
0

Problems importing XML into DataWindow

May 26, 2017 at 03:23 PM

127

avatar image
Former Member

I am trying to create a DataWindow that can import the following XML string. I have tried several times to create an import template but nothing works. I even tried stripping off the root element and that didn't help either. I am using PB 10.5 but have all versions of PB available.

<root totalResults="2" response="True"><result title="movie title 1" year="1977" imdbID="tt0076759" type="movie" poster="poster2.jpg"/><result title="movie title 2" year="1980" imdbID="tt0080684" type="movie" poster="poster2.jpg"/></root>

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
avatar image
Former Member May 27, 2017 at 06:30 PM
0

If you don't use a template, PB expects the fields to be in tags, not attributes.

The following template works with your data. Edit source and replace, or add, this template.

template=(comment="" encoding="UTF-16LE" name="IMDB_xml" xml="<?xml version=~"1.0~" encoding=~"UTF-16LE~" standalone=~"no~"?><root><result title=~"mtitle~" year=~"yr~" imdbID=~"imdbid~" type=~"mtype~" poster=~"postername~" __pbband=~"detail~"/></root>")

In the <result> tag, replace the names in double quotes to match your actual column names. On the Data Import tab of the datawindow properties, set format to configure to XML, and set the template to the new one (IMDB_xml).

I used PB 12.5 with your string, with a minor alteration. Add the "<?xml...?>" tag to the beginning of your string. It successfully imported two rows, from your XML with no changes.

Share
10 |10000 characters needed characters left characters exceeded