<Surety>
<SuretyLine>
<Commercial>
<Bond>
<General Information>
<BondName>abc</BondName>
</General Information>
<AddtionalInformation>
<div class="col-lg-12">
<Input Type="text" Name="additionalInfo_licenseNo" ID="additionalInfo_licenseNo" Onchange="fnSaveSingleData(this.name,'1')" Placeholder="Enter License No." Class="form-control" Title="License is required!" PrefillValue="No" Required="" />
</div>
</AddtionalInformation>
</Bond>
<Bond>
<General Information>
<BondName>xyz</BondName>
</General Information>
<AddtionalInformation>
<div class="col-lg-12">
<Input Type="text" Name="additionalInfo_licenseNo" ID="additionalInfo_licenseNo" Onchange="fnSaveSingleData(this.name,'1')" Placeholder="Enter License No." Class="form-control" Title="License is required!" PrefillValue="No" Required="" />
</div>
</AddtionalInformation>
</Bond>
</Commercial>
</SuretyLine>
</Surety>
ASKER
element.parent().find('.AddtionalInformation');
ASKER
<script>
function fnGetBondAdditionalInformation() {
$.ajax({
url: "http://localhost:5489/BondList.xml",
success: function (xml) {
parseSelectXMLBondAdditionalInformation(xml, "test", localStorage.getItem('bondState'), localStorage.getItem('bondName'))
},
error: function (xhr, ajaxOptions, thrownError) {
alert("Status: " + xhr.status);
alert("Error: " + thrownError);
}
});
}
function parseSelectXMLBondAdditionalInformation(xml, selectid, bondState, bondName) {
var html = "";
$(xml).find('Bond').each(function (i, e) {
{
if (bondState == $(e).find('GeneralInformation').find('State').text() && bondName == $(e).find('GeneralInformation').find('Name').text()) {
var selectedBondName = $(e).find('GeneralInformation').find('Name').text();
var selectedAdditionalInforation = $(e).find('AddtionalInformation').find('div').find('Input').text();
$('#test').text(selectedAdditionalInforation);
}
}
});
// alert(html);
}
window.onload = function () {
fnGetBondAdditionalInformation();
};
</script>
<script>
</script>
ASKER
<script>
function fnGetBondAdditionalInformation() {
$.ajax({
url: "http://localhost:5489/BondList.xml",
success: function (xml) {
parseSelectXMLBondAdditionalInformation(xml, "test", localStorage.getItem('bondState'), localStorage.getItem('bondName'))
},
error: function (xhr, ajaxOptions, thrownError) {
alert("Status: " + xhr.status);
alert("Error: " + thrownError);
}
});
}
function parseSelectXMLBondAdditionalInformation(xml, selectid, bondState, bondName) {
var html = "";
$(xml).find('Bond').each(function (i, e) {
{
if (bondState == $(e).find('GeneralInformation').find('State').text() && bondName == $(e).find('GeneralInformation').find('Name').text()) {
var selectedBondName = $(e).find('GeneralInformation').find('Name').text();
var selectedAdditionalInforation = $(e).find('AddtionalInformation').find('div').find('Input').text();
$('#test').text(selectedAdditionalInforation);
}
}
});
// alert(html);
}
window.onload = function () {
fnGetBondAdditionalInformation();
};
</script>
<p id="test"></p>
ASKER
function parseSelectXMLBondAdditionalInformation(xml, selectid, bondState, bondName)
Now look at this line of codeif (bondState == $(e).find('GeneralInformation').find('State').text() && bondName == $(e).find('GeneralInformation').find('Name').text()) {
Now look at your GeneralInformaion block in your XML<General Information>
<BondName>abc</BondName>
</General Information>
There is no State value in your XMLfunction parseSelectXMLBondAdditionalInformation(xml, selectid, bondState, bondName) {
var html = "";
$(xml).find('Bond').each(function (i, e) {
{
var gi = $(e).find('GeneralInformation');;
if (gi.find('BondName').text() == bondName) {
var ai = gi.parent().find('AddtionalInformation');
var text = ai.find('div > Input');//.text();
// THIS OUTPUTS AN EMPTY STRING BECAUSE input ELEMENTS
// DON'T HAVE A text PORTION
console.log(text);
}
}
});
// alert(html);
}
ASKER
ASKER
ASKER
1. You have invalid tags in your XML General Information has spaces in the name - this is not valid XML the element becomes General with an empty attribute Information
2. You are then searching for the text() of an Input - an Input does not have a text component.
Extensible Markup Language (XML) refers to the encoding of documents such that they can be read by both machines and humans. XML documents use tags to show the beginning and end of a set of data. XML is used extensively on websites to show volumes of data, and is the default for a number of office productivity suites. This topic includes discussions of XML-related technologies, such as XQuery (the XML Query language), XPath (the XML Path language), XSLT (eXtensible Stylesheet Language Transformations), XLink (the XML Linking language) and XPointer (the XML Pointer language).
TRUSTED BY