Invalid XML. ---> On A Plugin Containing FetchXML
up vote
0
down vote
favorite
This happens when there is &, or other invalid characters in the contract name. My question is, how do I deal with these invalid characters??!!
Microsoft.Crm.CrmException: Invalid XML. --->
System.Xml.XmlException: An error occurred while parsing EntityName.
Line 13, position 117.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32&
charRefEndPos)
at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at Microsoft.Crm.Platform.Server.Utility.XmlHelper.LoadXmlInfo(String
xmlInfo)
at Microsoft.Crm.Query.EntityExpression.ExtractPlatformName(String fetchXml, XElement element).
Here is the code in questions:
//run a fetchXml query to get how many contract lines have these values
string fetchLines = @"
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='new_yummycontractline'>
<attribute name='new_yummycontractlineid' />
<filter type='and'>
<condition attribute='new_servingtime' operator='eq' value='" + servingTime.ToString() + @"' />
<condition attribute='new_servinggroup' operator='eq' value='" + servingGroup.ToString() + @"' />
<condition attribute='new_destination' operator='eq' value='" + location.ToString() + @"' />
<condition attribute='statecode' operator='eq' value='0' />
</filter>
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' uiname='" + uiname + @"' uitype='new_yummycontract' value='" + contractId.ToString() + @"' />
</filter>
</link-entity>
</entity>
</fetch>";
EntityCollection results = service.RetrieveMultiple(new FetchExpression(fetchLines));
dynamics-crm dynamics-365 fetchxml
add a comment |
up vote
0
down vote
favorite
This happens when there is &, or other invalid characters in the contract name. My question is, how do I deal with these invalid characters??!!
Microsoft.Crm.CrmException: Invalid XML. --->
System.Xml.XmlException: An error occurred while parsing EntityName.
Line 13, position 117.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32&
charRefEndPos)
at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at Microsoft.Crm.Platform.Server.Utility.XmlHelper.LoadXmlInfo(String
xmlInfo)
at Microsoft.Crm.Query.EntityExpression.ExtractPlatformName(String fetchXml, XElement element).
Here is the code in questions:
//run a fetchXml query to get how many contract lines have these values
string fetchLines = @"
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='new_yummycontractline'>
<attribute name='new_yummycontractlineid' />
<filter type='and'>
<condition attribute='new_servingtime' operator='eq' value='" + servingTime.ToString() + @"' />
<condition attribute='new_servinggroup' operator='eq' value='" + servingGroup.ToString() + @"' />
<condition attribute='new_destination' operator='eq' value='" + location.ToString() + @"' />
<condition attribute='statecode' operator='eq' value='0' />
</filter>
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' uiname='" + uiname + @"' uitype='new_yummycontract' value='" + contractId.ToString() + @"' />
</filter>
</link-entity>
</entity>
</fetch>";
EntityCollection results = service.RetrieveMultiple(new FetchExpression(fetchLines));
dynamics-crm dynamics-365 fetchxml
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This happens when there is &, or other invalid characters in the contract name. My question is, how do I deal with these invalid characters??!!
Microsoft.Crm.CrmException: Invalid XML. --->
System.Xml.XmlException: An error occurred while parsing EntityName.
Line 13, position 117.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32&
charRefEndPos)
at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at Microsoft.Crm.Platform.Server.Utility.XmlHelper.LoadXmlInfo(String
xmlInfo)
at Microsoft.Crm.Query.EntityExpression.ExtractPlatformName(String fetchXml, XElement element).
Here is the code in questions:
//run a fetchXml query to get how many contract lines have these values
string fetchLines = @"
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='new_yummycontractline'>
<attribute name='new_yummycontractlineid' />
<filter type='and'>
<condition attribute='new_servingtime' operator='eq' value='" + servingTime.ToString() + @"' />
<condition attribute='new_servinggroup' operator='eq' value='" + servingGroup.ToString() + @"' />
<condition attribute='new_destination' operator='eq' value='" + location.ToString() + @"' />
<condition attribute='statecode' operator='eq' value='0' />
</filter>
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' uiname='" + uiname + @"' uitype='new_yummycontract' value='" + contractId.ToString() + @"' />
</filter>
</link-entity>
</entity>
</fetch>";
EntityCollection results = service.RetrieveMultiple(new FetchExpression(fetchLines));
dynamics-crm dynamics-365 fetchxml
This happens when there is &, or other invalid characters in the contract name. My question is, how do I deal with these invalid characters??!!
Microsoft.Crm.CrmException: Invalid XML. --->
System.Xml.XmlException: An error occurred while parsing EntityName.
Line 13, position 117.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32&
charRefEndPos)
at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at Microsoft.Crm.Platform.Server.Utility.XmlHelper.LoadXmlInfo(String
xmlInfo)
at Microsoft.Crm.Query.EntityExpression.ExtractPlatformName(String fetchXml, XElement element).
Here is the code in questions:
//run a fetchXml query to get how many contract lines have these values
string fetchLines = @"
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='new_yummycontractline'>
<attribute name='new_yummycontractlineid' />
<filter type='and'>
<condition attribute='new_servingtime' operator='eq' value='" + servingTime.ToString() + @"' />
<condition attribute='new_servinggroup' operator='eq' value='" + servingGroup.ToString() + @"' />
<condition attribute='new_destination' operator='eq' value='" + location.ToString() + @"' />
<condition attribute='statecode' operator='eq' value='0' />
</filter>
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' uiname='" + uiname + @"' uitype='new_yummycontract' value='" + contractId.ToString() + @"' />
</filter>
</link-entity>
</entity>
</fetch>";
EntityCollection results = service.RetrieveMultiple(new FetchExpression(fetchLines));
dynamics-crm dynamics-365 fetchxml
dynamics-crm dynamics-365 fetchxml
edited Nov 14 at 1:08
jasonscript
3,48611630
3,48611630
asked Nov 11 at 20:45
Alan Judi
26011
26011
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
uiname
and uitype
are not required for your fetchXml to work. These are used for presentation and not for the query. I think these are added by the Advanced Find editor; hence the "UI"
You can rewrite that section of XML like so
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' value='" + contractId.ToString() + @"' />
</filter>
</link-entity>
Not sure which version of .NET you're using, but you can also use the $
special character to indicate an interpolated string which I think increases readability and reduces string concatenation
string fetchLines = @$"
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='new_yummycontractline'>
<attribute name='new_yummycontractlineid' />
<filter type='and'>
<condition attribute='new_servingtime' operator='eq' value='servingTime' />
<condition attribute='new_servinggroup' operator='eq' value='servingGroup' />
<condition attribute='new_destination' operator='eq' value='location' />
<condition attribute='statecode' operator='eq' value='0' />
</filter>
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' value='contractId' />
</filter>
</link-entity>
</entity>
</fetch>";
add a comment |
up vote
0
down vote
I used webutility.htmlencode(uiname)
and the problem seems to have disappeared. I guess the uiname has some invalid XML characters and this method gets rid of the problem!
uiname
anduitype
are not required for your fetchXml to work. These are used for presentation and not for the query; hence the "UI"
– jasonscript
Nov 12 at 3:36
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
uiname
and uitype
are not required for your fetchXml to work. These are used for presentation and not for the query. I think these are added by the Advanced Find editor; hence the "UI"
You can rewrite that section of XML like so
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' value='" + contractId.ToString() + @"' />
</filter>
</link-entity>
Not sure which version of .NET you're using, but you can also use the $
special character to indicate an interpolated string which I think increases readability and reduces string concatenation
string fetchLines = @$"
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='new_yummycontractline'>
<attribute name='new_yummycontractlineid' />
<filter type='and'>
<condition attribute='new_servingtime' operator='eq' value='servingTime' />
<condition attribute='new_servinggroup' operator='eq' value='servingGroup' />
<condition attribute='new_destination' operator='eq' value='location' />
<condition attribute='statecode' operator='eq' value='0' />
</filter>
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' value='contractId' />
</filter>
</link-entity>
</entity>
</fetch>";
add a comment |
up vote
1
down vote
accepted
uiname
and uitype
are not required for your fetchXml to work. These are used for presentation and not for the query. I think these are added by the Advanced Find editor; hence the "UI"
You can rewrite that section of XML like so
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' value='" + contractId.ToString() + @"' />
</filter>
</link-entity>
Not sure which version of .NET you're using, but you can also use the $
special character to indicate an interpolated string which I think increases readability and reduces string concatenation
string fetchLines = @$"
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='new_yummycontractline'>
<attribute name='new_yummycontractlineid' />
<filter type='and'>
<condition attribute='new_servingtime' operator='eq' value='servingTime' />
<condition attribute='new_servinggroup' operator='eq' value='servingGroup' />
<condition attribute='new_destination' operator='eq' value='location' />
<condition attribute='statecode' operator='eq' value='0' />
</filter>
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' value='contractId' />
</filter>
</link-entity>
</entity>
</fetch>";
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
uiname
and uitype
are not required for your fetchXml to work. These are used for presentation and not for the query. I think these are added by the Advanced Find editor; hence the "UI"
You can rewrite that section of XML like so
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' value='" + contractId.ToString() + @"' />
</filter>
</link-entity>
Not sure which version of .NET you're using, but you can also use the $
special character to indicate an interpolated string which I think increases readability and reduces string concatenation
string fetchLines = @$"
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='new_yummycontractline'>
<attribute name='new_yummycontractlineid' />
<filter type='and'>
<condition attribute='new_servingtime' operator='eq' value='servingTime' />
<condition attribute='new_servinggroup' operator='eq' value='servingGroup' />
<condition attribute='new_destination' operator='eq' value='location' />
<condition attribute='statecode' operator='eq' value='0' />
</filter>
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' value='contractId' />
</filter>
</link-entity>
</entity>
</fetch>";
uiname
and uitype
are not required for your fetchXml to work. These are used for presentation and not for the query. I think these are added by the Advanced Find editor; hence the "UI"
You can rewrite that section of XML like so
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' value='" + contractId.ToString() + @"' />
</filter>
</link-entity>
Not sure which version of .NET you're using, but you can also use the $
special character to indicate an interpolated string which I think increases readability and reduces string concatenation
string fetchLines = @$"
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='new_yummycontractline'>
<attribute name='new_yummycontractlineid' />
<filter type='and'>
<condition attribute='new_servingtime' operator='eq' value='servingTime' />
<condition attribute='new_servinggroup' operator='eq' value='servingGroup' />
<condition attribute='new_destination' operator='eq' value='location' />
<condition attribute='statecode' operator='eq' value='0' />
</filter>
<link-entity name='new_yummycontract' from='new_yummycontractid' to='new_contractid' link-type='inner' alias='ad'>
<filter type='and'>
<condition attribute='new_yummycontractid' operator='eq' value='contractId' />
</filter>
</link-entity>
</entity>
</fetch>";
edited Nov 14 at 1:09
answered Nov 12 at 3:49
jasonscript
3,48611630
3,48611630
add a comment |
add a comment |
up vote
0
down vote
I used webutility.htmlencode(uiname)
and the problem seems to have disappeared. I guess the uiname has some invalid XML characters and this method gets rid of the problem!
uiname
anduitype
are not required for your fetchXml to work. These are used for presentation and not for the query; hence the "UI"
– jasonscript
Nov 12 at 3:36
add a comment |
up vote
0
down vote
I used webutility.htmlencode(uiname)
and the problem seems to have disappeared. I guess the uiname has some invalid XML characters and this method gets rid of the problem!
uiname
anduitype
are not required for your fetchXml to work. These are used for presentation and not for the query; hence the "UI"
– jasonscript
Nov 12 at 3:36
add a comment |
up vote
0
down vote
up vote
0
down vote
I used webutility.htmlencode(uiname)
and the problem seems to have disappeared. I guess the uiname has some invalid XML characters and this method gets rid of the problem!
I used webutility.htmlencode(uiname)
and the problem seems to have disappeared. I guess the uiname has some invalid XML characters and this method gets rid of the problem!
answered Nov 12 at 1:23
Alan Judi
26011
26011
uiname
anduitype
are not required for your fetchXml to work. These are used for presentation and not for the query; hence the "UI"
– jasonscript
Nov 12 at 3:36
add a comment |
uiname
anduitype
are not required for your fetchXml to work. These are used for presentation and not for the query; hence the "UI"
– jasonscript
Nov 12 at 3:36
uiname
and uitype
are not required for your fetchXml to work. These are used for presentation and not for the query; hence the "UI"– jasonscript
Nov 12 at 3:36
uiname
and uitype
are not required for your fetchXml to work. These are used for presentation and not for the query; hence the "UI"– jasonscript
Nov 12 at 3:36
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253064%2finvalid-xml-gt-on-a-plugin-containing-fetchxml%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown