Announcement
Collapse
No announcement yet.
XML Help
Collapse
This topic is closed.
X
X
-
Just as an update I can say that Python and this one little tip here has sparked a great deal. I now have something based on this here and using EasyGUI that will help in an Event Management system that has a hard time with large XML files. Since that system lets us know which file we can take it run it through my program back out to the consuming system and all happy. I've even wrote another that will take our EDI files and automate some other splits, merges and sends. Python even has some great tools to compile and even make it a true EXE.
- Top
- Bottom
-
OK. I see what is going on. I need to read up on Python and the lxml module but this is very encouraging and will finally force me to learn Python which I've been trying to do for a while.
EDIT: Done! That works exactly what I was wanting. Now I have my alternatives if something like this arises again which I think it will. Thanks! andystmartin!Last edited by MoonRise; Dec 06, 2013, 01:02 PM.
- Top
- Bottom
Leave a comment:
-
Sorry for the delay on this. Our EDI VAN actually has this solved BUT very similar to the above. A bit more fancy on their end. Nice software they have. I was at least able to help and see their software mapping tool in action. Anyway I still tried the code you provided. Had to make a slight change on the DOC.WRITE. %i+1 needed to be %(i+1). So, the issue now with it is this based on my test XML. Lets say NODE C has 5 CHILDREN NODES (D). The code actually produces 22 files and only the last 5 are the mostly correct ones. There are a few missing closes on some entries. Could the "pretty_print" be doing that? Anyway, this was real close to what I was wanting and for my own purposes I'm looking further into this as this will be of great value! Thanks! Much, Much Thanks!
- Top
- Bottom
Leave a comment:
-
The following little script reads a file 'text.xml', removes all the 'D' elements (child nodes of 'C') and inserts them one at a time. After each D element is reinserted, it writes out a new xml file.
test.xml:My solution uses the lxml python package:Code:<A> <B> <C> <D1/> <D2/> <D3/> <D4/> </C> </B> </A>Hope this helps.Code:[font=courier] #! /usr/bin/env python from lxml import etree doc = etree.parse('test.xml') root = doc.getroot() c = root.find('.//C') # find node with tag 'C' d = c.getchildren() # get all 'D' elements # delete all D elements that are children of C for i in range(len(d)): c.remove(d[i]) # Now add them in 1 at a time and save at each iteration for i in range(len(d)): c.append(d[i]) doc.write('file%d.xml' % i+1, pretty_print=True) # delete what was just added. c.remove(d[i])[/font]
- Top
- Bottom
Leave a comment:
-
You may then, want to look at jaxml -- http://www.librelogiciel.com/softwar...n_Presentation
- Top
- Bottom
Leave a comment:
-
Hmmmm... That was very close to what I was thinking. I'll have to Trial it and just see what it can actually do. I don't think quite what I want but still seems to be a very well put together editor. Again, Thanks!
- Top
- Bottom
Leave a comment:
-
XML editor yes but one that can be automated. A mapping software more than anything. Though I can say this part of OxygenXML intrigues me --> XML diff and merge. Thanks!
- Top
- Bottom
Leave a comment:
-
I don't really understand your question/need. But, it sounds like you want/need an XML editor?? Check out http://www.oxygenxml.com/download which includes a Linux version. Yes, it isn't free, but it does have a trial license key so you can try it.
- Top
- Bottom
Leave a comment:
-
This is an EDI process. The files can be hundreds of lines long so doing a manual process would be unproductive especially when you want the process to be automated as much as possible. We have someone currently looking at using a mapping tool that would do that. I was hoping there was some kind of mapping tool or something that could do that where we didn't have to hire it done but oh well. Thanks! I do appreciate the responses.
- Top
- Bottom
Leave a comment:
-
Do IUC? Copy the original four times, then delete the D parts not wanted from each?
A real, possibly obfuscated, example of the file would be helpful. I suspect vim text objects would make it a snap.
Regards, John Little
- Top
- Bottom
Leave a comment:
-
Thanks! As far as the artwork that has fallen victim to work. It has been really harsh this past year. This XML issue in point. Thing is, this vendor of ours is supposed to be "experts" and I know more than they and am having to find a solution to their lack of, well what ever you want to call what little they have! I'm sure a mapping type application would work but I don't have access to such a thing.
- Top
- Bottom
Leave a comment:
-
Hi moonrise!
have you done any of that absolutely marvy artwork lately! ?
As to your situation,....I indicated that all of that .xml crappola is in an attached file waaay back at Xandros...or maybe PClos.... but all that I, personally, could do was to "extract" the "stuff" in the non .xml part of the file, say in a word doc, the actual text.
The .xml part of the file was a kind of a "wrapper" that would somehow "enhance" the basic "text" so that maybe images, or whatnot, could be inserted/appended to the text ...supposedly to "enhance' it so that it would somehow better interact with "stuff" ..."on the web"....at least that was what Microsith said on their website.
And I was roundly ignored.
Here is a very tantgential comment by me...but back then Xandros was supposed to be the "saviour" of "Linux" so that the complainers would have "compatibility" with the all seeing eye of Sauron....

oooh sorry.... of Microsith.
http://archive.is/72Hzs
However..............I am WAAAY behind the times.....soooooo
HANG ON!!! somebody that is much more current on this will happen by in the nonce.
AAAND how about some more of that GREAT ARTWORK!!!
woodsmokeLast edited by woodsmoke; Nov 13, 2013, 10:55 PM.
- Top
- Bottom
Leave a comment:
Users Viewing This Topic
Collapse
There are 0 users viewing this topic.
Leave a comment: