• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Check is always false isXmlAttribute

Enthusiast ,
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

    Hi can anyone see why Check is always false isXmlAttribute in this case?

<cfset isNullCurrencyValue = true>
  <cfset CurrencyValue          = "">
 
<cfif isXmlAttribute(structFromParsedXML.XmlAttributes["CurrencyValue"])>
  <cfset isNullCurrencyValue = false>
  <cfset CurrencyValue   = structFromParsedXML.XmlAttributes["CurrencyValue"]>
  </cfif>

TOPICS
Advanced techniques

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

Without seeing your XML... no, no-one will be able to see why.

However the variable name sets off an alarm: "strucTFromParsedXML".  Sounds like a struct to me, not an XML object.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

cool, things like this always work in my cfm page

<cfqueryparam value="#structFromParsedXML.XmlAttributes["LineDiscountValue"]#" cfsqltype="cf_sql_varchar">

but this is always being set as null:

<cfqueryparam value="#CurrencyValue#" cfsqltype="cf_sql_varchar" null="#isNullCurrencyValue#">

but the xml with CurrencyValue sometimes does not have the attribute compare these:

<NewOrders SupplyMargin="1" SalesMargin="2" LineDiscountName="" LineDiscountValue="0"/>

with

<NewOrders SupplyMargin="1" SalesMargin="2" LineDiscountName="" LineDiscountValue="0" CurrencyValue = 200/>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

oh and the struct is beign set like this:

<cfset structFromParsedXML = GetDataFromFeed(parsedXML)>

<cfscript>
function GetDataFromFeed(xmlFeed)
{
var final = arrayNew(1);
var i = 1;
var j = 1;
var children = arrayNew(1);
allOrders = XmlSearch(xmlFeed, "ROOT/NewOrders");
return allOrders;
}
</cfscript>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 26, 2012 May 26, 2012

Copy link to clipboard

Copied

nikos101 wrote:

<cfset structFromParsedXML = GetDataFromFeed(parsedXML)>

Then it is actually an array. Hence:

<cfset arrayFromParsedXML = GetDataFromFeed(parsedXML)>

"ROOT/NewOrders"

Remember that the search is case-sensitive. Therefore, use the exact case of the elements root and newOrders.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 29, 2012 May 29, 2012

Copy link to clipboard

Copied

Look... we need to see:

a) sample XML

b) the code that creates structFromParsedXML

Not an extract of the XML.  Not a description of how you get it.  The actual XML.

And, similarly, the actual code that creates the variable.

I expect to be able to copy and paste the XML and code you provide, and run it myself here.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 29, 2012 May 29, 2012

Copy link to clipboard

Copied

Adam Cameron. wrote:

Look... we need to see:

b) the code that creates structFromParsedXML

See above.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 30, 2012 May 30, 2012

Copy link to clipboard

Copied

LATEST

Yeah, OK, thanks for that. I don't mean a function that takes some unknown input and has a bunch of unnecessary code and then does an xmlSearch() and returns that.  I mean the end-to-end code starting with the XML and finishing with the problem.  A repro case, basically.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation