Here I’m again asking for help….
Let’s see, I’ve the next situation, I made a module for manage the clients in a web platform, when some register is gonna be created the user selects a client from a select and when a client is selected I make a request to get all the client data, one of these data is a XML string, which contains some structure (different for each client) and the user must fill some content in the nodes if the XML, for example, this is the XML structure for one client:
<?xml version="1.0"?>
<cfdi xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///c:/Users/dlucas/Desktop/Addendas%20XSD/Kuehne.xsd">
<AD>
<RECEPTION>
<Tipo>
<INVOICE>
<!--Element Purchase_Order is optional-->
<Order>string</Order>
<!--Element FileNumber_GL is optional-->
<GL>string</GL>
<Centre>string</Centre>
<Ref>string</Ref>
</INVOICE>
</Tipo>
</RECEPTION>
</AD>
</cfdi>
What I trying to do is that when the XML string is received process it and generate a HTML form with the XML tags (Order, GL, Centre and Ref) or all the tags inside the INVOICE tag… but this changes on every client’s XML.
I’ve been searching for some javascript library, but I believe it doesn’t not exist, not for convert the xml to a form… I found this project: http://www.datamech.com/XMLForm/ this is exactly what I need to do, and describes the structure of a XML and the types of Data Entry and Advanced Editing that this tool makes, I’ve tested this tool and works perfectly this the XML of this example, buy sadly this post doesn’t explain or gives some resource for made this work, that’s so sad!!
After this I tried to made it manually, but my ability to process and iterate the XML string is so poor (I know I’ve to practice more… and I’m on the way) but if someone could give me a hand to make this task I’ll be so grateful!
I’ve inspected the result os this tool, and this is the structure of the form:
<div id="xmlForm">
<form name="xmlForm" action="http://www.datamech.com/XMLForm/formXML0200.pl?.df=html" target="_blank" method="post">
<div class="XMLcomplexContent">
<fieldset class="cfdi">
<legend>cfdi</legend>
<input type="hidden" value="cfdi" name=".tg">
<input type="hidden" name="@
xmlns:xsi" value="http://www.w3.org/2001/XMLSchema-instance">
<input type="hidden" name="@xsi:noNamespaceSchemaLocation" value="file:///c:/Users/dlucas/Desktop/Addendas%20XSD/Kuehne.xsd">
<div class="XMLcomplexContent">
<fieldset class="Addenda">
<legend>Addenda</legend>
<input type="hidden" value="Addenda" name=".tg">
<div class="XMLcomplexContent">
<fieldset class="KNRECEPCION">
<legend>KNRECEPCION</legend>
<input type="hidden" value="KNRECEPCION" name=".tg">
<div class="XMLcomplexContent">
<fieldset class="Tipo">
<legend>Tipo</legend>
<input type="hidden" value="Tipo" name=".tg">
<div class="XMLcomplexContent">
<fieldset class="FacturasKN">
<legend>FacturasKN</legend>
<input type="hidden" value="FacturasKN" name=".tg">
<span class="XMLsimpleType">
<span class="Purchase_Order">
<label>Purchase_Order: </label>
<input type="text" class="Purchase_Order" name="Purchase_Order" value="string" onfocus="focusGained(this)" onchange="textChanged(this)">
</span>
<br>
</span>
<span class="XMLsimpleType">
<span class="FileNumber_GL">
<label>FileNumber_GL: </label>
<input type="text" class="FileNumber_GL" name="FileNumber_GL" value="string" onfocus="focusGained(this)" onchange="textChanged(this)">
</span>
<br>
</span>
<span class="XMLsimpleType">
<span class="Branch_Centre">
<label>Branch_Centre: </label>
<input type="text" class="Branch_Centre" name="Branch_Centre" value="string" onfocus="focusGained(this)" onchange="textChanged(this)">
</span>
<br>
</span>
<span class="XMLsimpleType">
<span class="TransportRef">
<label>TransportRef: </label>
<input type="text" class="TransportRef" name="TransportRef" value="string" onfocus="focusGained(this)" onchange="textChanged(this)">
</span>
<br>
</span>
<input type="hidden" value="/FacturasKN" name=".tg">
</fieldset>
</div>
<input type="hidden" value="/Tipo" name=".tg">
</fieldset>
</div>
<input type="hidden" value="/KNRECEPCION" name=".tg">
</fieldset>
</div>
<input type="hidden" value="/Addenda" name=".tg">
</fieldset>
</div>
<input type="hidden" value="/cfdi" name=".tg">
</fieldset>
</div>
<p>
<input id="submit" type="submit" value="Generate XML">
<input value="Reset" type="reset">
</p>
</form>
</div>
And this is what it looks like on the browser:

Is important to say that when the user click in the save button the content of the form must be converted to a XML string but with the values that the user typed in the form…
I know this is a hard task, buy really I’ll appreciate some help, now I’m so confused, I’ll be working on this and if some progress is made I’ll communicate with yours…