C# XML Writer Format AmazonEnvelope for AU Scratchpad

99封情书 提交于 2019-12-24 21:04:58

问题


OK so I'm trying to format this XML element so that it looks like this:

<AmazonEnvelope xsi:noNamespaceSchemaLocation="amzn-envelope.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

This is the code I have so far:

writer.WriteAttributeString("xsi", "noNamespaceSchemaLocation", null, "amzn-envelope.xsd");
writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");

Now this code outputs this XML element:

<AmazonEnvelope noNamespaceSchemaLocation="amzn-envelope.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

So it's almost there but the xsi: is missing before this noNamespaceSchemaLocation

I really don't know where I'm going wrong.

Also I have been in touch with amazon devs and they tell me that it must be formatted like I have asked. Though if you do some googling you will notice examples of the xml writer code which will output the following XML element:

<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">

This is wrong, and gives an error in the scratch pad.

I hope my question makes sense.

thanks for the help.

来源:https://stackoverflow.com/questions/47427705/c-sharp-xml-writer-format-amazonenvelope-for-au-scratchpad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!