English 中文(简体)
通过多个主机 XML 文件搜索字符串
原标题:Search through multiple hosted XML files for a string
I m working on a website that uses a lot of XML-files as data (150 in total and probably growing). Each page is an XML-file. What I m looking for is a way to look for a string through the XML-files. I m not sure what programming language to use for this XML search engine. I m familiar with PHP, JavaScript, JQuery. So I d prefer using those languages. Thanks a bunch! UPDATE: I m looking for a solution that works quickly. Ideally, the function returns the tagname that contains the searchstring. If, for instance, the XML is as follows: This is a great story. If one would search for story , it would return article-1 . I m not quite sure on how to do this with a regular expression.
最佳回答
PHP can do this. Here s an example: foreach(glob("{foldera/*.xml,folderb/*.xml}",GLOB_BRACE) as $filename) { $xml = simplexml_load_file($filename); //use regular expressions to find your string } You simply iterate through each file on your server using glob() with a foreach loop.
问题回答
Sounds like a problem that could be solved with grep and regular expressions. Without knowing what string you re looking for it s not possible to say exactly what you should do, but reading some documentation on grep should get you started down the right path.




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签