Sublime Forum

XML commands for sublime text

#1

Hey,

I just had an idea that I think would be nice. It’s an xml Parser inside Sublime Text.

For example, say you want to add a label to all of your inputs in HTML. You would write something like this:

inputs=document.getElementsByTagName('input')
for input in inputs:
    id=input.getAttribute('id')
    label=document.createElement('label').setAttribute('for',id)
    input.before(label)

Is they already support for something like that in Sublime Text, or are they some plugins that extend sublime this way ?
If not, how is it possible to do so ? I never created a plugin and am asking if you can add variables like that accessible from the sublime console.

Thanks in advance!

0 Likes

#2

I don’t know if a plugin like that exist (I wouldn’t be surprised if there is one). But you can do it to. Off the top of my head, I would say you could read in the file content using view.substr(0, view.file_size()). Pass that content to an XML manipulation library (which I’m sure python has). Perform whatever manipulation you want (gathering information from the user via input panel). Then replace the content of the file with the manipulated information.

0 Likes