Jump to content

Import Pages XML


justb3a
 Share

Recommended Posts

This ProcessWire module allows you to import and parse XML files (using xpath) to create or update pages. [detailed instructions at github]
 
screencast.gif
 
Settings
 
After successfull installation go to Setup > Import Pages From XML to start using the XML Importer.

This module does not support all available field types. Nevertheless, I've refrained from restricting the supported field types because many of them should work by default.
 
Xpath Mappings
 
If you want to take advantage of references between fields in your xpath mapping then make sure the fields you're relating to are placed before the ones which need the relations. You can access and use any values/fields that you placed earlier in your file. Use $field_<fieldname> to match the desired value.
 
Example:
 

<?xml version="1.0" encoding="UTF-8"?>

<songs>
    <song track="2">
        <title contact_id="1">Some song title</title>
    </song>
    <song track="7">
        <title contact_id="2">Just another song title</title>
    </song>
    <contact id="1" name="Sesmallbos" mail="info@test.org"/>
    <contact id="2" name="Sebigbos" mail="info@exam.ple"/>
</songs>
  • context: //song
  • field order: title, track, contact_id, contact_name, contact_mail
  • contact_id must be placed before contact_name and contact_mail
  • first get contact_id : title/@contact_id
  • then use that value as relation : //contact[@id=$field_artist_id]/@name as well as //contact[@id=$field_artist_id]/@mail
  • Like 14
Link to comment
Share on other sites

  • 2 months later...

<mod note>

Hi @louisstephens,

Please note that this forum (ProcessWire Support Forums  → Community Support  → Modules/Plugins) is a support board for existing modules only. If you your question is about module development, please use its sub-forum (ProcessWire Support Forums  → Community Support  → Modules/Plugins  → Module/Plugin Development), If it's about a specific module and that module has its own support thread, please post your question in that thread (however long the thread might be (for now) - it will still be picked up). I am moving your thread to its appropriate forum.

</mod note>

Link to comment
Share on other sites

  • 3 weeks later...

Sorry for the late reply, somehow I missed your answer. As I understand, you want to combine fields. This is not possible at the moment. How did you solve your request? If you need any hookable function, just let me know, I'll add it.

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

thanks for your answer. I have no current solution. I need to fill the $map->address value. I will try to export my XML with combined data. Example

Street postal code city in one value but how to fill only $map->address

the $map variable has three values

$map->lat

$map->lng also

Link to comment
Share on other sites

  • 1 month later...

hi,

first: thanks for your work.

I've got a question to importing text withing cdata. 

If i map the title field from: 

<name><!--[CDATA[foo, bar - foobar]]--></name>

i got the following error:

You may not modify 'name' on page '/processwire/access/roles/guest/' because it is a system page

Any idea to import the name field correctly?

Link to comment
Share on other sites

  • 5 months later...

I'm getting the following error trying to install module to PW 3.0.34.

Do you think it's a version 3 compatibility issue or a configuration on my end?

Thanks! 

Error: Call to undefined function Jos\Lib\wire() (line 34 of /Applications/MAMP/htdocs/pw3/site/modules/ImportPagesXml/lib/Parser.php) 

 

Link to comment
Share on other sites

the master branch / version from pw module directory wasn't PW 3.x ready. Previously you had to use branch develop. But I just released a new version 1.0.0 which supports ProcessWire 3.x (only). Just update the module to the latest version and everything should work as expected. :) 

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...