How to update XML in ntext column?

How do I create an interface to update an XML template?

  • How do I go about creating a simple interface to update only certain specific nodes in different XML templates? I have several XML templates which I use over and over again, updating the same specific nodes every time. At present I just do this by searching for the name of the node in the document, nexting through until I find the right ones, and then pasting in the new text. It strikes me that an interface which asks me to enter only the specific data I need to change and then updates the template for me would be a great great improvement - I do I go about creating such a thing, or where would I go to start learning how to do so? (One caveat - there are multiple versions of the same nodes within the template, but I only need to update certain ones. So, for example, there are 20 "album" tags, each of which has let's say 10 "song" tags each, but I only need to update the 3rd song of the 5th album every time I reuse the template.) Although I've never done anything like this before - and I only have basic programming knowledge - I'm *imagining* that creating an interface (a web interface?) which allows me to enter the template path and the new specific data shouldn't be brain surgery. I can learn pretty fast, and I'm looking at this half as a way to make my life easier, and half as a great opportunity to learn how to do something new.

  • Answer:

    Ignoring the fact that it's XML, you could probably write something in PHP that gets the input from a form and just does the oldecho "<XML etc ec".$_GET['value'].">";type thing, and spits it out. (note: that example would open you up to XSS if you put it online. it's just a synopsis.) But I don't see this happening without some knowledge of PHP or a similar scripting language...

The_Partridge_Family at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Other answers

Hmm, if you have access to the full office suite, take a look at InfoPath 2007, it very well might do what you need... Alternatively , What I'm doing right now involves a xml file which has one configurable value based on where the application gets installed to. I replaced that value with @config_dir@ and then just search and replace that text automatically. It would be a 3-4 line script in ruby or perl to find and replace the value with a inputed string and then save off to another file.

cschneid

the token replacement trick that cschneid mentions is the easiest approach assuming that there is a unique, fixed number of items that you are replacing. I'd also add that when you replace the token with your text, that you be sure to escape it for characters that are not proper to be appearing in that location of the xml document. This would include characters like > or <.

mmascolino

hmm - I have InfoPath and it appears to be excellent for *creating* a form to change specific areas of a template, but updating the template seems uber-complicated involving submission to a database or Web server: I just want it to update an XML file on my desktop!

The_Partridge_Family

That sounds like a relatively simple XSL transformation. I say "sounds like" because it's only simple if you can reduce the requirements for which bits of data you're changing to a simple formula. Are your updating tasks easy to codify, as in, will it always be something like this?"attribute 'length' of song where number = X of album where name = Y needs changing to '<new data>'" If you can always reduce your needs to the same list of parameters (attribute-name, song-number, album-title, new data) then it will be easy.

AmbroseChapel

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.