I used this github php code
https://github.com/kodekrash/wikipedia.org-xmldump-mongodb
get the dataset by
wget -c http://wikipedia.c3sl.ufpr.br/enwiki/20150901/enwiki-20150901-pages-articles.xml.bz2
quite large 12GB
changed the correponding configuration
$dsname = 'mongodb://wiki:wiki@localhost:27017/wikipedia';
$file = '../data/enwiki-20150901-pages-articles.xml.bz2';
$logpath = './';
and run from the command line
php wikipedia.org-xmldump-mongodb.php
get error:
PHP Warning: simplexml_load_string(): Entity: line 37: parser error : expected '>' in /home/username/wiki-project/wikipedia.org-xmldump-mongodb/wikipedia.org-xmldump-mongodb.php on line 73
PHP Warning: simplexml_load_string(): </namespaces> in /home/username/wiki-project/wikipedia.org-xmldump-mongodb/wikipedia.org-xmldump-mongodb.php on line 73
PHP Warning: simplexml_load_string(): ^ in /home/username/wiki-project/wikipedia.org-xmldump-mongodb/wikipedia.org-xmldump-mongodb.php on line 73
PHP Warning: simplexml_load_string(): Entity: line 38: parser error : Premature end of data in tag namespace line 34 in /home/username/wiki-project/wikipedia.org-xmldump-mongodb/wikipedia.org-xmldump-mongodb.php on line 73
PHP Warning: simplexml_load_string(): in /home/username/wiki-project/wikipedia.org-xmldump-mongodb/wikipedia.org-xmldump-mongodb.php on line 73
PHP Warning: simplexml_load_string(): ^ in /home/username/wiki-project/wikipedia.org-xmldump-mongodb/wikipedia.org-xmldump-mongodb.php on line 73
PHP Warning: simplexml_load_string(): Entity: line 38: parser error : Premature end of data in tag namespaces line 1 in /home/username/wiki-project/wikipedia.org-xmldump-mongodb/wikipedia.org-xmldump-mongodb.php on line 73
PHP Warning: simplexml_load_string(): in /home/username/wiki-project/wikipedia.org-xmldump-mongodb/wikipedia.org-xmldump-mongodb.php on line 73
PHP Warning: simplexml_load_string(): ^ in /home/username/wiki-project/wikipedia.org-xmldump-mongodb/wikipedia.org-xmldump-mongodb.php on line 73
Aborting. Unable to parse namespaces.
I have installed
php, mbstring, simpleXML, mongodb extensions and mongodb 2.69
output of
php -m
is
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
mhash
mongo
openssl
pcntl
pcre
PDO
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
zip
zlib
[Zend Modules]
does anyone have idea about this error ? thanks
You have to escape the >
character. In the script file, on line 72 replace this line:
$chunk = str_replace( [ 'letter">', '</namespace>' ], [ 'letter" name="', '" />' ], $chunk );
With:
$chunk = str_replace( [ 'letter"\>', '</namespace\>' ], [ 'letter" name="', '" /\>' ], $chunk );
That made it work for me!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.