xmlns 到 sharepoint api 对象

发布于 2024-09-11 03:33:04 字数 388 浏览 9 评论 0原文

是否可以将以下字符串转换为 Sharepoint API 对象,例如 SPUser 或 SPUserValueField? (不解析它)

"<my:Person xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD\"><my:DisplayName>devadmin</my:DisplayName><my:AccountId>GLINTT\\devadmin</my:AccountId><my:AccountType>User</my:AccountType></my:Person>"

谢谢, 大卫·埃斯蒂夫斯

Is it possible to convert the following string to a Sharepoint API object like SPUser or SPUserValueField? (without parsing it)

"<my:Person xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD\"><my:DisplayName>devadmin</my:DisplayName><my:AccountId>GLINTT\\devadmin</my:AccountId><my:AccountType>User</my:AccountType></my:Person>"

Thanks,
David Esteves

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡看悲欢离合 2024-09-18 03:33:04

是的,Microsoft.Office.Workflow.Utility 程序集具有 Contact.ToContacts,它将把 Person XML 反序列化为 Contact 实例数组。

http://msdn.microsoft.com/en-us/library/ms553588

-奥辛

Yes, the Microsoft.Office.Workflow.Utility assembly has Contact.ToContacts which will deserialize Person XML into an array of Contact instances.

http://msdn.microsoft.com/en-us/library/ms553588

-Oisin

毁虫ゝ 2024-09-18 03:33:04

解决了:)

(只是一个例子)
以下函数从 person 检索 SPUser:

protected SPUser GetSPUserFromExtendedPropertiesDelegateTo(string xmnls_node)
    {

        StringBuilder oBuilder = new StringBuilder();
        System.IO.StringWriter oStringWriter = new System.IO.StringWriter(oBuilder);
        System.Xml.XmlTextWriter oXmlWriter = new System.Xml.XmlTextWriter(oStringWriter);
        oXmlWriter.Formatting = System.Xml.Formatting.Indented;

        byte[] byteArray = Encoding.ASCII.GetBytes(xmnls_node);
        MemoryStream stream = new MemoryStream(byteArray);
        System.IO.Stream s = (Stream)stream;

        System.IO.StreamReader _xmlFile = new System.IO.StreamReader(s);

        string _content = _xmlFile.ReadToEnd();
        System.Xml.XmlDocument _doc = new System.Xml.XmlDocument();
        _doc.LoadXml(_content);

        System.Xml.XPath.XPathNavigator navigator = _doc.CreateNavigator();
        System.Xml.XmlNamespaceManager manager = new System.Xml.XmlNamespaceManager(navigator.NameTable);

        manager.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD");

        System.Xml.XmlNode _node = _doc.SelectSingleNode("/my:Person/my:AccountId", manager);

        if (_node != null)
        {

           return this.workflowProperties.Web.EnsureUser(_node.InnerText.ToString());

        }

        return null;


    }

Solved :)

(Just an example)
The following function retrieves the SPUser from person:

protected SPUser GetSPUserFromExtendedPropertiesDelegateTo(string xmnls_node)
    {

        StringBuilder oBuilder = new StringBuilder();
        System.IO.StringWriter oStringWriter = new System.IO.StringWriter(oBuilder);
        System.Xml.XmlTextWriter oXmlWriter = new System.Xml.XmlTextWriter(oStringWriter);
        oXmlWriter.Formatting = System.Xml.Formatting.Indented;

        byte[] byteArray = Encoding.ASCII.GetBytes(xmnls_node);
        MemoryStream stream = new MemoryStream(byteArray);
        System.IO.Stream s = (Stream)stream;

        System.IO.StreamReader _xmlFile = new System.IO.StreamReader(s);

        string _content = _xmlFile.ReadToEnd();
        System.Xml.XmlDocument _doc = new System.Xml.XmlDocument();
        _doc.LoadXml(_content);

        System.Xml.XPath.XPathNavigator navigator = _doc.CreateNavigator();
        System.Xml.XmlNamespaceManager manager = new System.Xml.XmlNamespaceManager(navigator.NameTable);

        manager.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD");

        System.Xml.XmlNode _node = _doc.SelectSingleNode("/my:Person/my:AccountId", manager);

        if (_node != null)
        {

           return this.workflowProperties.Web.EnsureUser(_node.InnerText.ToString());

        }

        return null;


    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文