将KML文件加载到mysql/xpath和x quires [英] Loading KML file in to mysql / xpath and x quires
问题描述
您好,我在加载大型kml文件时遇到了一些问题 我最初使用的是冷聚变,但无法处理大型xml/kml文件
hello im coming across a few problems on loading a large kml file i was originally using cold fusion but it just cant handle the large xml/kml files
所以我以为id使用php为它提供了重击,我对php和Coldfusion还是很陌生
so i thought id give it a bash using php i am fairly new to php and coldfusion
,因此您可以从 http://marinetraffic2.aegean中获取正在处理的kmz文件. gr/ais/getkml.aspx 您将不得不将其重命名为.zip,然后将其展开,然后在其中应该有一个名为doc.kml的kml文件,将其更改为xml,然后您就可以在它的开头找到一个Bom了,我在cfhttp上找到了它,然后键入= ut-8 something,然后删除前3个字符
so you can get the kmz file ive been working on from http://marinetraffic2.aegean.gr/ais/getkml.aspx you will have to rename it to .zip then expand it there should be a kml file in there called doc.kml change it to xml and there you go there is a Bom at the start of it i got round that on the cfhttp and type=ut-8 thingy then removing the first 3 chars
现在我遇到问题的部分正在加载xpath或对其进行任何查询
now the part i am having problems with is loading the xpaths or any queries on it
在将其放入数据库之前,我想将其放入一个要使用的数组中 我需要的是名称坐标styleurl和描述
i would like to put this is to an array to work with before i put it in to a data base there colums that i need are name coordinates styleurl and descriptions
我想得到这个但要工作
$dom = new DomDocument();
$dom->load("http://localhost/testdocs/bigdoc.xml");
$titles = $dom->getElementsByTagName("coordinates");
foreach($titles as $node) {
print $node->textContent . "<br> ";
}
这将返回xml文件中的名称列表
this will return the list of names in the xml file
但这就是所有这些,我需要的路径是kml/Document/Folder/Placemark/(名称为yada yada)
but thats all of them the path that i need would be kml/Document/Folder/Placemark/ (name yada yada)
谁能拥有一双新鲜的眼睛
can someone with a fresh pair of eyes
冷聚变的碎片在这里挂了好久了,但是当我尝试使用同样小的文件时
the bit in cold fusion just hanged there for ages but when i tried on the same much smaller file it worked
对php来说我是新手,但与冷熔不同,这一点点代码对大文件有效
so im new to php but that little bit of code works on the large file unlike cold fusion
好,主要问题是xpaths查询无法通过/folder
okey the main problem is that xpaths queries are just not working past the /folder
我希望你能理解我的杂话
i hope you can kinda understand my ramblings
感谢您对高级的帮助 JC
thanks for your help in advanced JC
推荐答案
DomDocument()在资源方面非常昂贵.我使用 XMLReader()来解析很大的XML文件(> 600MB)而没有问题.
DomDocument() is very expensive in terms of resources. I use XMLReader() to parse very large XML files ( > 600MB) without problems.
看一下文档: http://php.net/manual/zh /book.xmlreader.php
这篇关于将KML文件加载到mysql/xpath和x quires的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!