开发者

How can I better understand and navigate the structure of large XML files

I'm slogging through a somewhat large XML file. Say I'm looking for a particular value within the tree. I find it manually, but then to find it programmatically I need to know the path. Rig开发者_运维问答ht now, I'm usingtidy and vim to pretty-print the file so that can I inspect it manually. It's getting old real fast though, 'cause the file is over 30,000 lines. So when I found the aforementioned value, it's quite a challenge to determine the full path. Ideally, I'd like a tool that'll let me do a full search on the contents of the xml file, and then display the full tree path to the root. This question has some awesome suggestions, but all of them are Windows only. Is there anything for Macs out there?


There are some strong XML tools for the Mac as well. Specifically, if you are interested in the path, I like using the XML editor of Eclipse. If you download the Helios version (go for the "Eclipse IDE for JavaScript Web Developers"), you can set it as your default XML editor (in the Finder, set the Open With) and it has very solid tools for outlining an XML and shows the path in the status bar.

There are other tools, GIYF.


I use a combination of vim, xmllint, xpath, and a tool called cgrep, which you can find at http://plg1.cs.uwaterloo.ca/~ftp/mt/cgrep/ .

vim is my standard editor.

xmllint is essential if you are doing xml development.

xpath comes with xmllint iirc, and is a clumsy but workable command-line xpath evaluator.

cgrep is an experimental grep that uses cascading shortest-match regexes which can be very useful for quickly parsing record oriented files (xml, ini, properties, yaml, etc). I often find this much more useful than xpath.

Note that if you are using gcc to build it, it does require some simple bug fixes as it is written in archaic C - I'm happy to send you a copy of the patched up code if you are interested.


If the end goal is to have a Mac program to read and deal with the XML then I'd recommend you take a look at the tool and the code from this Apple-provided sample: http://developer.apple.com/mac/library/samplecode/XMLBrowser/Introduction/Intro.html

You can browse the XML and also test out various XQuery strings to see what is returned.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜