Get or Set Xmlfield values

  • 19 December 2006
  • 1 reply
  • 0 views

Badge +3
Hi,

I'm trying to get an xmlfield value, set with a smartform. In the workspace, I see my xmlfield value is ok :


- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <User>
<Name>toto4</Name>
<Address>toto4@toto</Address>
</User>

</xs:schema>


But with this code (generate with the data manipulation event), I have an error :
.Value = TargetField;
K2.Synchronous = true;
}


And the error is :

System.Exception: XPath : "Root/User/Name" could not be resolved on this document.
at SourceCode.K2Utilities.XmlFieldHelper.XMLValueInternal(XmlDocument poXMLDoc, String psXPath, Object pValue, String psMethod)
at SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(String xml, String XPath)
at K2Code1850.Main(ServerEventContext& K2)


I don't understand what's wrong ...
In my XmlField miss the root element.
I built this xmlfield in a smartform like that :
.Value = doc.OuterXml; 
pi.Update();

connexion.Close();


Thx

Aude

1 reply

Badge +1
It seems to me you are looking in XPath for:

Root/User/Name

But your actual XML document:

User/Name

Reply