コード例 #1
0
 public static function getValue($szXMLVariable, $xtlTagList, &$szValue)
 {
     $boReturnValue = false;
     $lszHierarchicalNames;
     $szXMLTagName;
     $szLastXMLTagName;
     $nCount = 0;
     $xtCurrentTag = null;
     $xaXmlAttribute = null;
     $lXmlTagAttributeList;
     if (xtlTagList == null) {
         $szValue = null;
         return false;
     }
     $lszHierarchicalNames = new CSV_StringList();
     $szValue = null;
     $lszHierarchicalNames = CSV_SharedFunctions::getStringListFromCharSeparatedString($szXMLVariable, '.');
     if (count($lszHierarchicalNames) == 1) {
         $szXMLTagName = $lszHierarchicalNames->getAt(0);
         $xtCurrentTag = CSV_SharedFunctions::GetNamedTagInTagList($szXMLTagName, $xtlTagList);
         if ($xtCurrentTag != null) {
             $lXmlTagAttributeList = $xtCurrentTag->getAttributes();
             $xaXmlAttribute = $lXmlTagAttributeList->getAt($szXMLTagName);
             if ($xaXmlAttribute != null) {
                 $szValue = $xaXmlAttribute->getValue();
                 $boReturnValue = true;
             } else {
                 $szValue = $xtCurrentTag->getContent();
                 $boReturnValue = true;
             }
         }
     } else {
         if (count($lszHierarchicalNames) > 1) {
             $szXMLTagName = $lszHierarchicalNames->getAt(0);
             $szLastXMLTagName = $lszHierarchicalNames->getAt($lszHierarchicalNames->getCount() - 1);
             // need to remove the last variable from the passed name
             for ($nCount = 1; $nCount < $lszHierarchicalNames->getCount() - 1; $nCount++) {
                 $szXMLTagName .= "." . $lszHierarchicalNames->getAt($nCount);
             }
             $xtCurrentTag = CSV_SharedFunctions::getNamedTagInTagList($szXMLTagName, $xtlTagList);
             // first check the attributes of this tag
             if ($xtCurrentTag != null) {
                 $lXmlTagAttributeList = $xtCurrentTag->getAttributes();
                 $xaXmlAttribute = $lXmlTagAttributeList->getXmlAttributeForAttributeName($szLastXMLTagName);
                 if ($xaXmlAttribute != null) {
                     $szValue = $xaXmlAttribute->getValue();
                     $boReturnValue = true;
                 } else {
                     // check to see if it's actually a tag
                     $xtCurrentTag = CSV_SharedFunctions::getNamedTagInTagList($szLastXMLTagName, $xtCurrentTag->getChildTags());
                     if ($xtCurrentTag != null) {
                         $szValue = CSV_SharedFunctions::replaceEntitiesInStringWithChars($xtCurrentTag->getContent());
                         $boReturnValue = true;
                     }
                 }
             }
         }
     }
     return $boReturnValue;
 }