1
I need to generate the xml
, but without skipping line, the way I Gero he is all identado, as I do to save without skipping the line?
document.LoadXml(soapEnvelope);
document.Save(@"E:\nota.xml");
I tried this code below:
XDocument document = XDocument.Load("arquivo.xml");
document.Save("arquivo2.xml", SaveOptions.DisableFormatting);
But the option does not appear SaveOptions
, utilise ASP.NET CORE
.
This is the whole method:
private void montaEnvelope(HttpWebRequest webRequest, XmlDocument document)
{
string soapEnvelope = string.Empty;
soapEnvelope += "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ws=\"http://ws.issweb.fiorilli.com.br/\" xmlns:xd=\"http://www.w3.org/2000/09/xmldsig#\">";
soapEnvelope += "<soapenv:Header/><soapenv:Body><ws:gerarNfse>";
soapEnvelope += document.LastChild.OuterXml.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", string.Empty);
soapEnvelope += "<username>01001001000113</username><password>123456</password></ws:gerarNfse></soapenv:Body></soapenv:Envelope>";
MemoryStream stream = stringToStream(soapEnvelope);
webRequest.ContentLength = stream.Length;
Stream requestStream = webRequest.GetRequestStream();
stream.WriteTo(requestStream);
document.LoadXml(soapEnvelope);
document.Save(@"E:\nota.xml");
XDocument document1 = XDocument.Load(@"E:\nota.xml");
this.XmlDocNFSe = document;
}
Are you sure? Because it’s inside the
namespace
System.Xml.Linq
, you added?– novic
@Virgilionovic when I put
System.Xml.Linq
he lets me put theSaveOptions.DisableFormatting
, but it returns this Error No overload for "Save" method takes 2 arguments– Mariana
Too weird ... !
– novic
@Virgilionovic just edited with the entire function, so you can see how is being declared the
document
. Thank you.– Mariana
Which version of netframework?
– novic
@Virgilionovic uses 4.7.2 and the core is 2.1
– Mariana
Xmldocument doesn’t even have you already right the class name
– novic
I don’t know what you mean.
– Mariana
In your parameter is Xmldocument which is different from Xdocument you are missing in classes where Xdocument really has the overload with Saveoptions already Xmldocument does not have this overload !!!
– novic