rmmarsh
asked on
Why can't I get past the first three attributes?
I have the following small XML file, where I store my program settings:
I access them, in order, with this code snippet:
The problem is that the code will not process any of the items past "tabSettings".
How do I fix this?
<Prager>
<CannedText tTextTitle1="Fast Shipping!" tCannedDesc1="Still in manufacturer wrapping! Fast Shipping! Ships within 24 hours! 100% Satisfaction guaranteed!" tTextTitle2="Repl w/ title" tCannedDesc2="" tTextTitle3="Repl w/ title" tCannedDesc3="" tTextTitle4="Repl w/ title" tCannedDesc4="" tTextTitle5="Repl w/ title" tCannedDesc5="" tTextTitle6="Repl w/ title" tCannedDesc6="" tTextTitle7="Repl w/ title" tCannedDesc7="" tTextTitle8="Repl w/ title" tCannedDesc8="" tTextTitle9="Repl w/ title" tCannedDesc9="" tTextTitle10="Repl w/ title" tCannedDesc10="" tTextTitle11="Repl w/ title" tCannedDesc11="" tTextTitle12="Repl w/ title" tCannedDesc12="" tTextTitle13="Repl w/ title" tCannedDesc13="" tTextTitle14="Repl w/ title" tCannedDesc14="" tTextTitle15="Repl w/ title" tCannedDesc15="" tTextTitle16="Repl w/ title" tCannedDesc16="" tTextTitle17="Repl w/ title" tCannedDesc17="" tTextTitle18="Repl w/ title" tCannedDesc18="" />
<ProgramOptions oAutoPricing="false" oVerifyDeletes="true" oBackupDB="true" oAutoSKU="true" oWarnNoCat="false" oWarnNoLoc="false" oGenCustNbr="true" oGenInvNbr="true" oAutoFileRetn="true" oToolTipsOff="true" oStartPanelSearch="false" oCurrEnglish="false" oCurrEuro="false" oCurrUS="false" oMoveAvgPrice="false" oMoveLowPrice="false" oUseAWS="true" oNoDesc="false" oAWSKey="084BT0EPNB27A07DGR82" oAWSSecretKey="Gk0QGlcORtiSZQxqGiifKyiarqmyf9jcS1U/5Eyw" oAZAssocTag="pragbook-20" oMerchantID="A20V78MULJSCYR" oMarketplaceID="ATVPDKIKX0DER" oHalfDotComToken="AgAAAA**AQAAAA**aAAAAA**uYiHRw**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wJnYuhDpaLoAmdj6x9nY+seQ**DAsAAA**AAMAAA**y9/8TcAmm8gCijqwhSxxWsHg3QjnRqpzB+LbUldfNMOvWQVUPHSoPEYFPa0QXm/Ekgg5cUvKg8RRxHC3swHT+RSG6w144BcSbc4GjPdJ7Z7oOO84qwUJwb1Ufxk9dqSxxpusnSmqjF8vxDsD7ovqzAaRsqhZGhriy8ZeuymnnHW5pufSvMD9ZAM/MgdlJ45NM3O+eQPXuez2gh4oHraTx1R0Akg4RtKzxgjQl4lLfp3r9IGM0lh2ZP56PnYfdDAMdKAbcIyPo3tN86tCCqZabWNZuRY5UQDaQbBEySyLb0/FUGzwq9AhMSxAKI0hX0wZK//PTuKFUoZIDrIDYT21Bj7bUqGo9OAnMV2NSkA+Zivchd3vCDrHE+Ebi0CoFKa2aGksnE7pXMjVC3NeGC3TIE5vKf7AnpqCBbDJe+SpQSXU+aIxPgkaU7GAUH+kn2ONJZO77BKxIR75/nB+vw/LIUZAKOI8TH1c3NvXxLszm3Sed+x4dE6nyPlNAR+BypaWgPpwqU2x6HEZjYb/WYC9SNWDmNkZJUi/xluAiagZvi4eDG+JwGxsEbw6/dHGCQ3rrk1e2NZNdiEwVtPOqlx/f99HM1Gd34AUf08yA+t9ztapul+nzAdsna4V4zdIrYmjAbXeaaYkTNpMDQzxOIvmWLcAXjXI1AOoPQHUSRTh3Q+fJ7DJukyRgT9AOnKd1kiLa0Z1ni0ucEH1XRYK9k7zLnXFISCOIBro5Y4Mkl7h4MkPWMNh728zIES22QCtmW8l " oSortOverride="false" oSortAsc="false" oSortDsc="false" oAllowAddUpdate="false" oUseReceipt="false" />
<tabSettings oUPCSeq="0" oQtySeq="0" oLocSeq="0" oSKUSeq="0" oCostSeq="0" oPriceSeq="0" oRePriceSeq="260" oTitleSeq="0" oASignedSeq="0" oPubSeq="0" oYearSeq="0" oDescSeq="0" oCannedSeq="250" oCondSeq="0" oJacketSeq="345" oEdSeq="353" oTypeSeq="355" />
<UploadSelections uAmazon="false" uAmazonUK="false" uAlibris="false" uBandN="false" uPapaMedia="false" uScribblemonger="false" uHalfDotCom="false" uChrislands="false" uCS1="false" uCS2="false" uCS3="false" uCS4="false" />
<ExportSelections xAlibris="true" xAmazon="true" xBarnes="true" xChrislands="true" xHalf="true" xPapaMedia="true" />
<RepricingSelections highByAmt="" whatPriceH="-1" lowByAmt="" whatPriceL="-1" newByAmt="" newWhatPrice="-1" condAmtVG="" condAmtG="" condAmtP="" belowMyCostOr="" discardBelowAmt="" discardAboveAmt="" priceLowPct="false" greaterSugg="true" lessSugg="true" highBelow="false" priceHighPct="false" lowBelow="false" dontGoBelowCost="false" priceNewPct="false" />
<Miscellaneous mPictureFilename="" mBusinessAddress="Logo goes above; place your address here. Maximum of 64 characters on two lines." mReceiptWidth="" mStoreName="" />
<CustomSites customSite1="Custom Site 1" customSite2="Custom Site 2" customSite3="Custom Site 3" customSite4="Custom Site 4" />
</Prager>
I access them, in order, with this code snippet:
if (File.Exists(xmlFilename)) {
using (XmlReader tr = XmlReader.Create(xmlFilename)) {
try {
while (tr.Read()) // If the node has value
{
if (tr.IsStartElement("CannedText")) {
if (tr.GetAttribute("tTextTitle1").Contains("Repl w/ title") == false) {
tbCannedTitle1.Text = tr.GetAttribute("tTextTitle1");
tbCannedDesc1.Text = tr.GetAttribute("tCannedDesc1");
lbCannedText.Items.Add(tbCannedTitle1.Text);
}
if (tr.GetAttribute("tTextTitle2").Contains("Repl w/ title") == false) {
tbCannedTitle2.Text = tr.GetAttribute("tTextTitle2");
tbCannedDesc2.Text = tr.GetAttribute("tCannedDesc2");
lbCannedText.Items.Add(tbCannedTitle2.Text);
}
}
if (tr.IsStartElement("ProgramOptions")) {
if (tr.GetAttribute("oAutoPricing") == "true")
cbAutoPricingLookup.Checked = true;
else cbAutoPricingLookup.Checked = false;
if (tr.GetAttribute("oVerifyDeletes") == "true")
cbVerifyDeletes.Checked = true;
else cbVerifyDeletes.Checked = false;
}
if (tr.IsStartElement("tabSettings")) {
if (tr.GetAttribute("oUPCSeq").Length > 0)
tbUPC.TabIndex = Convert.ToInt32(tr.GetAttribute("oUPCSeq"));
if (tr.GetAttribute("oQtySeq").Length > 0)
tbQty.TabIndex = Convert.ToInt32(tr.GetAttribute("oQtySeq"));
}
if (tr.IsStartElement("UploadSelections")) {
if (tr.GetAttribute("uAmazon") == "true" && tbMarketplaceID.Text.Length > 0 && tbMerchantID.Text.Length > 0)
cbUploadAmazon.Checked = true;
else
cbUploadAmazon.Checked = false;
if (tr.GetAttribute("uAmazonUK") == "true" && tbAWSKey.Text.Length > 0 && tbAWSSecretKey.Text.Length > 0)
cbUploadAmazonUK.Checked = true;
else
cbUploadAmazonUK.Checked = false;
}
The problem is that the code will not process any of the items past "tabSettings".
How do I fix this?
What do you mean by, " the code will not process any of the items past 'tabSettings'"? I tested your code in a new project, and it seemed to process correctly. UploadSelections was retrieved as expected.
ASKER
GREAT! I didn't want to hear that! :D
When I put debug breakpoints on each of the lines that checks for the Start Element (lines 6, 19, 29 and 36). only the first three stop... the remainder are ignored (there are more than what I show).
When I put debug breakpoints on each of the lines that checks for the Start Element (lines 6, 19, 29 and 36). only the first three stop... the remainder are ignored (there are more than what I show).
ASKER
Do you want to see the complete code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Kenneth... I found it... it's a pilot error on my part... there is an exception when processing the "tab settings" attributes.
Thanks for your help...
Rolf (Spokane-Dude)
Thanks for your help...
Rolf (Spokane-Dude)