Trying to provide a user with editable XML page in a browser.
For example, the following is part of an XML.
<Employee name="John Doe" type="contract" ID="1000">
<Salary>10000</Salary>
<Email>[email protected]</Email>
</Employee>
When the above is presented to the user in a brower (either IE or FF), the user should be able to highlight an attribute or the value. When highlighted and the second mouse button is pressed, this would pop up a menu for editing. For attributes and tags, it could be something like ID-TEST-PRESENT or ID-TEST-OPTIONAL. Now instead of ID, the attribute should change to ID-TEST-PRESENT when selected.
Likewise, for values, a text box can be presented, where the user can enter a new value. Then this updated XML file needs to be sent to the back end and saved.
Is this doable? If yes, what would be the easiest way.
I have always written embedded applications. This is my first foray on the web browser side. Any help is appreciated.
XML Viewer. Open the XML file quickly and for free inside the Google Chrome browser. Open and edit your XML files instantly for free using this software. You can open and edit your XML files directly on the Google Chrome Browser and save these changes directly onto your desktop.
XML files are encoded in plaintext, so you can open them in any text editor and be able to clearly read it. Right-click the XML file and select "Open With." This will display a list of programs to open the file in. Select "Notepad" (Windows) or "TextEdit" (Mac).
View an XML file in a browser If all you need to do is view the data in an XML file, you're in luck. Just about every browser can open an XML file. In Chrome, just open a new tab and drag the XML file over. Alternatively, right click on the XML file and hover over "Open with" then click "Chrome".
Create a new XML or XSLT fileFrom the File menu, select New. The New File dialog box appears. Select XML File to create a new XML file; or, select XSLT File to create a new XSLT style sheet. Select Open.
It is doable of course, but it's not trivial. At least not for someone who is not used to Javascript and manipulating the DOM. You would have to parse the XML and create a HTML document with Javascript event listeners on each element.
You could try and use an existing component and modify it if necessary. I found a similar question here:
https://stackoverflow.com/questions/378205/web-xml-editor-with-xml-syntax-highlighting
Unless you are dealing with generic XML files, you are probably better off just reading the XML and generate a standard HTML form. The simplest way would be to base everything on a database that will export to XML to the backend processes if needed. This makes it much simpler to add/edit multiple rows of data
One way to to create an interface for editing information in a particular XML vocabulary is to use XForms. (I think it is by far the easiest and best, but YMMV.) Given an appropriate infrastructure (see below), using XForms for what you describe would involve:
As you can see, it's a little simpler than rolling your own using AJAX (at least once you have the infrastructure set up).
What infrastructure is necessary for XForms depends in part on which XForms implementation you are using.
For client-based implementations of XForms (such as XSLTForms from AgenceXML, or Formula from EMC), you need (a) a copy of the software on your server (in the case of XSLTForms, this means one XSLT stylesheet, one Javascript library, and one CSS file), (b) possibly an appropriate link in the form itself (how this needs to be done varies with the implementation), and (c) a server willing to accept PUT requests. In some contexts, it will be (c) that is the hardest to get set up, but any server that provides a WebDAV interface will do, so SVN with auto-versioning, Apache (alone or on top of Subversion), and other tools can all be used.
For server-based implementations (such as Orbeon Forms or BetterForm), you need to install the XForms implementation and run it on your Web server; since they are typically servlets, you will need to put them in a servlet engine. In general, they will ship with some form of WebDAV server included.
Steven Pemberton of W3C and CWI has written a helpful tutorial introduction to XForms; I maintain a list of pointers to that and to other XForms-related materials that may also be helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With