Remove/Hide elements specified in a xsl-fo file in .Net - c#

In an xsl-fo file how can I remove some elements

Quickest way, perhaps not the most elegant :
XmlDocument xmlDoc = new XmlDocument();
StringBuilder xmlSb = new StringBuilder();
xmlSb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
xmlSb.AppendLine("<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">");
xmlSb.AppendLine(" <fo:layout-master-set>");
xmlSb.AppendLine(" <fo:simple-page-master master-name=\"master\">");
xmlSb.AppendLine(" <fo:region-body margin-bottom=\"0.5in\" margin-top=\"0.9in\" margin-left=\"35pt\"/>");
xmlSb.AppendLine(" <fo:region-before region-name=\"xsl-region-before\" extent=\"0.9in\"/>");
xmlSb.AppendLine(" <fo:region-after region-name=\"xsl-region-after\" extent=\"0.5in\"/>");
xmlSb.AppendLine(" </fo:simple-page-master>");
xmlSb.AppendLine(" </fo:layout-master-set>");
xmlSb.AppendLine(" <fo:page-sequence master-reference=\"master\"/>");
xmlSb.AppendLine("</fo:root>");
// Load xml from string
xmlDoc.LoadXml(xmlSb.ToString());
Console.WriteLine("----- Original xml -----");
Console.WriteLine(xmlSb.ToString());
// Select region-before node
XmlNode regionBeforeNode = xmlDoc.SelectSingleNode("//*[local-name()='region-before']");
// Remove region-before node
regionBeforeNode.ParentNode.RemoveChild(regionBeforeNode);
// Select region-after node
XmlNode regionAfterNode = xmlDoc.SelectSingleNode("//*[local-name()='region-after']");
// Remove region-after node
regionAfterNode.ParentNode.RemoveChild(regionAfterNode);
Console.WriteLine("----- Nodes removed -----");
StringBuilder sbOut = new StringBuilder();
// Pretty indented output
XmlWriterSettings settings = new XmlWriterSettings
{
Indent = true,
IndentChars = " ",
NewLineChars = "\r\n",
NewLineHandling = NewLineHandling.Replace
};
using (XmlWriter writer = XmlWriter.Create(sbOut, settings))
{
xmlDoc.Save(writer);
}
Console.WriteLine(sbOut.ToString ());

Try xml linq :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args)
{
string xml =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
"<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">" +
" <fo:layout-master-set>" +
" <fo:simple-page-master master-name=\"master\">" +
" <fo:region-body margin-bottom=\"0.5in\" margin-top=\"0.9in\" margin-left=\"35pt\"/>" +
" </fo:simple-page-master>" +
" </fo:layout-master-set>" +
" <fo:page-sequence master-reference=\"master\"/>" +
"</fo:root>";
XDocument doc = XDocument.Parse(xml);
XNamespace nsFo = doc.Root.GetNamespaceOfPrefix("fo");
XElement regionBody = doc.Descendants(nsFo + "region-body").FirstOrDefault();
regionBody.Add(new XElement(nsFo + "test", new object[] { new XAttribute("name", "John")}));
}
}
}

Related

Repeated writing in different XMLfiles

I need to write GPS-Data in different XMLfiles. The files need to have the following format:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx>
<metadata>
<time>YYYY-MM-DDTHH:MM:SSZ</time>
</metadata>
<trk>
<name>YYYY-MM-DDTHH:MM:SSZ</name>
<trkseg>
<trkpt lat="12.1795" lon="12.3456">
<ele>-46.97</ele>
<time>YYYY-MM-DDTHH:MM:SSZ</time>
</trkpt>
// more trkpt
</trkseg>
</trk>
</gpx>
I tried to do it with an XMLwriter. At first it constructs the part till trkpt.That works. The XmlWriterSettings were included because the Error told me to use ConformanceLevel "Auto" or "fregmented" ,but that didn't solve my issue.
XmlWriterSettings setting = new XmlWriterSettings();
setting.ConformanceLevel = ConformanceLevel.Auto;
setting.Indent = true;
DateTime localDate = DateTime.Now;
xmlWriter[0] = XmlWriter.Create("testbase.xml", setting);
for (int i = 1; i < (numOfXMLWriter); i++)
{
xmlWriter[i] = XmlWriter.Create(test[i].Text, setting);
}
int tmp = 0;
foreach (XmlWriter writer in xmlWriter)
{
writer.WriteStartDocument(true);
writer.WriteStartElement("gpx");
writer.WriteStartElement("metadata");
writer.WriteStartElement("time");
writer.WriteString(localDate.Year + "-" + localDate.Month + "-" + localDate.Day + "T" + localDate.Hour + ":" + localDate.Minute + ":" + localDate.Second);
writer.WriteEndElement(); //time
writer.WriteEndElement(); //metadata
//trk + name
writer.WriteStartElement("trkseg");
}
Later the received GPS-Data is written as individual trkpt.
xmlWriter[id].WriteStartElement("trkpt");
xmlWriter[id].WriteAttributeString("lat", splitData[4]);
xmlWriter[id].WriteAttributeString("lon", splitData[6]);
xmlWriter[id].WriteStartAttribute("ele");
xmlWriter[id].WriteString("0");
xmlWriter[id].WriteEndElement(); //</ele>
xmlWriter[id].WriteStartElement("time");
xmlWriter[id].WriteString(splitData[10][4] + splitData[10][5] + "-" + splitData[10][2] + splitData[10][3] + "-" + splitData[10][0] + splitData[10][1] + "T" + splitData[2][0] + splitData[2][1] + ":" + splitData[2][2] + splitData[2][3] + ":" + splitData[2][4] + splitData[2][5] + "Z");
xmlWriter[id].WriteEndElement(); //</time>
xmlWriter[id].WriteEndElement(); //</trkpt>
The Error says:
InvalidOperationException: "Token StartElement in state EndRootElement would result in an invalid XML document”
I think this is because the XMLwriter Closes all the nodes atomatically and later i try to add another Node on root Level. Is there a possibility to stap the writer from ending the document on it's own?
Thanks for your help!
Jonas
Using xml linq
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication1
{
class Program
{
const string FILENAME = #"c:\temp\test.xml";
static void Main(string[] args)
{
string header = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?><gpx></gpx>";
XDocument doc = XDocument.Parse(header);
XElement gpx = doc.Root;
gpx.Add(new object[] {
new XElement("metadata"), new XElement("time", DateTime.Now.ToString("yyyy-MM-ddthh:mm:ssz")),
new XElement("trk", new object[] {
new XElement("name", DateTime.Now.ToString("yyyy-MM-ddthh:mm:ssz")),
new XElement("trksseg", new object[] {
new XElement("trkpt", new object[] {
new XAttribute("lat", 12.1795),
new XAttribute("lon", 12.3456),
new XElement("ele", -46.97),
new XElement("time",DateTime.Now.ToString("yyyy-MM-ddthh:mm:ssz")),
})
})
})
});
}
}
}

How to add XNamespace (Xml.Linq) to XElement? [duplicate]

Question update: im very sorry if my question is not clear
here is the code im using right now
XDocument doc = XDocument.Parse(framedoc.ToString());
foreach (var node in doc.Descendants("document").ToList())
{
XNamespace ns = "xsi";
node.SetAttributeValue(ns + "schema", "");
node.Name = "alto";
}
and here is the output
<alto p1:schema="" xmlns:p1="xsi">
my goal is like this
xsi:schemaLocation=""
where does the p1 and xmlns:p1="xsi" came from?
When you write
XNamespace ns = "xsi";
That's creating an XNamespace with a URI of just "xsi". That's not what you want. You want a namespace alias of xsi... with the appropriate URI via an xmlns attribute. So you want:
XDocument doc = XDocument.Parse(framedoc.ToString());
foreach (var node in doc.Descendants("document").ToList())
{
XNamespace ns = "http://www.w3.org/2001/XMLSchema-instance";
node.SetAttributeValue(XNamespace.Xmnls + "xsi", ns.NamespaceName);
node.SetAttributeValue(ns + "schema", "");
node.Name = "alto";
}
Or better, just set the alias at the root element:
XDocument doc = XDocument.Parse(framedoc.ToString());
XNamespace ns = "http://www.w3.org/2001/XMLSchema-instance";
doc.Root.SetAttributeValue(XNamespace.Xmlns + "xsi", ns.NamespaceName);
foreach (var node in doc.Descendants("document").ToList())
{
node.SetAttributeValue(ns + "schema", "");
node.Name = "alto";
}
Sample creating a document:
using System;
using System.Xml.Linq;
public class Test
{
static void Main()
{
XNamespace ns = "http://www.w3.org/2001/XMLSchema-instance";
XDocument doc = new XDocument(
new XElement("root",
new XAttribute(XNamespace.Xmlns + "xsi", ns.NamespaceName),
new XElement("element1", new XAttribute(ns + "schema", "s1")),
new XElement("element2", new XAttribute(ns + "schema", "s2"))
)
);
Console.WriteLine(doc);
}
}
Output:
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<element1 xsi:schema="s1" />
<element2 xsi:schema="s2" />
</root>

Two identical namespaces with dirfferent prefixes in XDocument

So, I try creating Xml document with next code:
XNamespace spr1 = "urn:schemas-microsoft-com:office:spreadsheet";
XNamespace ex = "urn:schemas-microsoft-com:office:excel";
XNamespace spr2 = "urn:schemas-microsoft-com:office:spreadsheet";
XNamespace rec = "http://www.w3.org/TR/REC-html40";
var xworkbook = new XElement(spr1 + "Workbook");
xworkbook.Add(new XAttribute(XNamespace.Xmlns + "x", ex));
xworkbook.Add(new XAttribute(XNamespace.Xmlns +"ss", spr2));
xworkbook.Add(new XAttribute(XNamespace.Xmlns + "html", rec));
This code make next xml:
<ss:Workbook xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
<!--Xml body-->
</ss:Workbook>
But I expect this:
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
</Workbook>
How to build Workbook element without "ss" prefix and with needed "xmlns" attribute?
LINQ to XML uses the namespace prefix that is closest as it looks through all the attributes in reverse order from the current element to the root. So if you add the default namespace explicitly at the end, then Workbook will use that and not the ss prefix.
XNamespace ss = "urn:schemas-microsoft-com:office:spreadsheet";
XNamespace ex = "urn:schemas-microsoft-com:office:excel";
XNamespace html = "http://www.w3.org/TR/REC-html40";
var workbook = new XElement(
ss + "Workbook",
new XAttribute(XNamespace.Xmlns + "x", ex),
new XAttribute(XNamespace.Xmlns + "ss", ss),
new XAttribute(XNamespace.Xmlns + "html", html),
new XAttribute("xmlns", ss)
);
This gives you the XML below:
<Workbook xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="urn:schemas-microsoft-com:office:spreadsheet" />
As stated in the comments, the two documents in your question are semantically the same. Any XML parser shouldn't care about the difference between the two documents.
I usually do it like this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string xml =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
"<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"" +
" xmlns:x=\"urn:schemas-microsoft-com:office:excel\"" +
" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"" +
" xmlns:html=\"http://www.w3.org/TR/REC-html40\">" +
"</Workbook>";
XDocument doc = XDocument.Parse(xml);
XElement workbook = (XElement)doc.FirstNode;
XNamespace ssNs = workbook.GetNamespaceOfPrefix("ss");
XElement worksheet = new XElement(ssNs + "Worksheet");
workbook.Add(worksheet);
}
}
}

Get Innertext from an XML string which has only one node without looping

I have an XML string which looks like below
<?xml version="1.0" encoding="Windows-1252"?><Product><ID>0701161476416</ID><UNIQUE_ID>test26051602</UNIQUE_ID><STATUS>DONE</STATUS></Product>
It is know that my XML string will always has a single node ans so I do not want to look, instead I would like to get Unique_ID and Status inner values without looping.
May I know a better way to do it and I do have the below code which actually loops through each node
XmlDocument xm = new XmlDocument();
xm.LoadXml(XML_STRING);
XmlNodeList xnList = xm.SelectNodes("/Product/Product");
foreach (XmlNode xn in xnList)
{
string uniqueID = xn["UNIQUE_ID"].InnerText;
string status = xn["STATUS"].InnerText;
}
There is SelectSingleNode() which you can use for this purpose :
XmlNode product = xm.SelectSingleNode("/Product/Product");
string uniqueID = product["UNIQUE_ID"].InnerText;
string status = product["STATUS"].InnerText;
Or, if Product is the root element, then you can access it from DocumentElement property of the XmlDocument :
XmlNode product = xm.DocumentElement;
string uniqueID = product["UNIQUE_ID"].InnerText;
string status = product["STATUS"].InnerText;
If you have more than one product try xml linq
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string xml =
"<?xml version=\"1.0\" encoding=\"Windows-1252\"?>" +
"<Products>" +
"<Product>" +
"<ID>0701161476416</ID>" +
"<UNIQUE_ID>test26051603</UNIQUE_ID>" +
"<STATUS>DONE</STATUS>" +
"</Product>" +
"<Product>" +
"<ID>0701161476417</ID>" +
"<UNIQUE_ID>test26051604</UNIQUE_ID>" +
"<STATUS>DONE</STATUS>" +
"</Product>" +
"<Product>" +
"<ID>0701161476418</ID>" +
"<UNIQUE_ID>test26051605</UNIQUE_ID>" +
"<STATUS>DONE</STATUS>" +
"</Product>" +
"</Products>";
XDocument doc = XDocument.Parse(xml);
var results = doc.Descendants("Product").Select(x => new
{
id = (long)x.Element("ID"),
uniqueID = (string)x.Element("UNIQUE_ID"),
status = (string)x.Element("STATUS")
}).ToList();
}
}
}
This could work, but I guess there is a better solution:
XDocument xm = XDocument.Parse(XML_STRING);
var product = xm.Element("Product").Element("Product");
string uniqueID = product.Element("UNIQUE_ID").Value;
string status = product.Element("STATUS").Value;
Your SelectNodes line seemed wrong for the sample Xml.
XmlNodeList xnList = xm.SelectNodes("/Product");
if (xnList.Count > 0)
{
string uniqueID = xnList[0]["UNIQUE_ID"].InnerText;
string status = xnList[0]["STATUS"].InnerText;
}

Trying to create xml in c# from xml schema using XDocument and XmlSchemaSet

I am trying to create a xml document that need to be serialized against some xml schemas. This is the result now
<?xml version="1.0" encoding="utf-8"?>
<StandardBusinessDocument>
<StandardBusinessDocumentHeader>
<HeaderVersion>1,0</HeaderVersion>
<Sender>
<Identifier>5790000011032</Identifier>
</Sender>
<Receiver>
<Identifier>5790000500000</Identifier>
</Receiver>
<DocumentIdentification>
<Standard>EAN.UCC</Standard>
<TypeVersion>2.8</TypeVersion>
<InstanceIdentifier>DI-35346-34535-xt435345</InstanceIdentifier>
<Type>catalogueItemNotification</Type>
<CreationDateAndTime>2013-12-20T10:46:26+00:00</CreationDateAndTime>
</DocumentIdentification>
</StandardBusinessDocumentHeader>
</StandardBusinessDocument>
And here is what it should look like.
<?xml version="1.0" encoding="utf-8"?>
<sh:StandardBusinessDocument xmlns:sh="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader" xmlns:eanucc="urn:ean.ucc:2" xmlns:gdsn="urn:ean.ucc:gdsn:2" xmlns:align="urn:ean.ucc:align:2" xmlns:chemical_ingredient="urn:ean.ucc:align:chemical_ingredient:2" xmlns:food_beverage_tobacco="urn:ean.ucc:align:food_beverage_tobacco:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader http://www.gdsregistry.org/2.8/schemas/sbdh/StandardBusinessDocumentHeader.xsd urn:ean.ucc:2 http://www.gdsregistry.org/2.8/schemas/CatalogueItemNotificationProxy.xsd urn:ean.ucc:2 http://www.gdsregistry.org/2.8/schemas/AttributeValuePairExtensionProxy.xsd urn:ean.ucc:2 http://www.gdsregistry.org/2.8/schemas/CaseLevelNonGTINLogisticsUnitExtensionProxy.xsd urn:ean.ucc:2 http://www.gdsregistry.org/2.8/schemas/TradeItemExtensionSpecificsProxy.xsd urn:ean.ucc:2 http://www.gdsregistry.org/2.8/schemas/ChemicalIngredientExtensionProxy.xsd urn:ean.ucc:2 http://www.gdsregistry.org/2.8/schemas/FoodAndBeverageTradeItemExtensionProxy.xsd">
<sh:StandardBusinessDocumentHeader>
<sh:HeaderVersion>1.0</sh:HeaderVersion>
<sh:Sender>
<sh:Identifier Authority="EAN.UCC">5790000011032</sh:Identifier>
</sh:Sender>
<sh:Receiver>
<sh:Identifier Authority="EAN.UCC">5790000500000</sh:Identifier>
</sh:Receiver>
<sh:DocumentIdentification>
<sh:Standard>EAN.UCC</sh:Standard>
<sh:TypeVersion>2.8</sh:TypeVersion>
<sh:InstanceIdentifier>DI-35346-34535-xt435345</sh:InstanceIdentifier>
<sh:Type>catalogueItemNotification</sh:Type>
<sh:CreationDateAndTime>2013-12-20T10:46:26+00:00</sh:CreationDateAndTime>
</sh:DocumentIdentification>
</sh:StandardBusinessDocumentHeader>
</sh:StandardBusinessDocument>
What i have so far in the method where i create the xml is this.
XmlSchemaSet sbdSchema = new XmlSchemaSet();
sbdSchema.Add("http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader", "D:\\Europoultry\\Program\\EPWCF\\EPSystem\\EPSystem\\XMLSchemas\\sdbh\\StandardBusinessDocumentHeader.xsd");
sbdSchema.Add("http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader", "D:\\Europoultry\\Program\\EPWCF\\EPSystem\\EPSystem\\XMLSchemas\\sdbh\\DocumentIdentification.xsd");
sbdSchema.Add("http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader", "D:\\Europoultry\\Program\\EPWCF\\EPSystem\\EPSystem\\XMLSchemas\\sdbh\\BasicTypes.xsd");
sbdSchema.Add("http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader", "D:\\Europoultry\\Program\\EPWCF\\EPSystem\\EPSystem\\XMLSchemas\\sdbh\\BusinessScope.xsd");
sbdSchema.Add("http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader", "D:\\Europoultry\\Program\\EPWCF\\EPSystem\\EPSystem\\XMLSchemas\\sdbh\\Manifest.xsd");
sbdSchema.Add("http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader", "D:\\Europoultry\\Program\\EPWCF\\EPSystem\\EPSystem\\XMLSchemas\\sdbh\\Partner.xsd");
XDocument doc = new XDocument(
new XElement("StandardBusinessDocument",
new XElement("StandardBusinessDocumentHeader",
new XElement("HeaderVersion", "1,0"),
new XElement("Sender",
new XElement("Identifier", "5790000011032")),
new XElement("Receiver",
new XElement("Identifier", "5790000500000")),
new XElement("DocumentIdentification",
new XElement("Standard", "EAN.UCC"),
new XElement("TypeVersion", "2.8"),
new XElement("InstanceIdentifier", "DI-35346-34535-xt435345"),
new XElement("Type", "catalogueItemNotification"),
new XElement("CreationDateAndTime", "2013-12-20T10:46:26+00:00")
)))
);
var savePath = "C:\\GS1TradeSyncItem.xml";
doc.Save(savePath);
I dont think the schemas is being importet right since the element dont have some attibutes on them, but i am not sure if this is what the problem is. Hope one of you can help.
Thanks!
Here is how I would add the namespaces
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication1
{
class Program
{
const string savePath = #"C:\temp\test.xml";
static void Main(string[] args)
{
string identification =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?> " +
"<sh:StandardBusinessDocument" +
" xmlns:sh=\"http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader\"" +
" xmlns:eanucc=\"urn:ean.ucc:2\" " +
" xmlns:gdsn=\"urn:ean.ucc:gdsn:2\" " +
" xmlns:align=\"urn:ean.ucc:align:2\" " +
" xmlns:chemical_ingredient=\"urn:ean.ucc:align:chemical_ingredient:2\" " +
" xmlns:food_beverage_tobacco=\"urn:ean.ucc:align:food_beverage_tobacco:2\"" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
" xsi:schemaLocation=\"http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader http://www.gdsregistry.org/2.8/schemas/sbdh/StandardBusinessDocumentHeader.xsd" +
" urn:ean.ucc:2 http://www.gdsregistry.org/2.8/schemas/CatalogueItemNotificationProxy.xsd" +
" urn:ean.ucc:2 http://www.gdsregistry.org/2.8/schemas/AttributeValuePairExtensionProxy.xsd" +
" urn:ean.ucc:2 http://www.gdsregistry.org/2.8/schemas/CaseLevelNonGTINLogisticsUnitExtensionProxy.xsd" +
" urn:ean.ucc:2 http://www.gdsregistry.org/2.8/schemas/TradeItemExtensionSpecificsProxy.xsd" +
" urn:ean.ucc:2 http://www.gdsregistry.org/2.8/schemas/ChemicalIngredientExtensionProxy.xsd" +
" urn:ean.ucc:2 http://www.gdsregistry.org/2.8/schemas/FoodAndBeverageTradeItemExtensionProxy.xsd\"" +
"/>";
XDocument doc = XDocument.Parse(identification);
XElement standardBusinessDocument = doc.Root;
XNamespace sh = standardBusinessDocument.Name.Namespace;
standardBusinessDocument.Add(
new XElement(sh + "StandardBusinessDocumentHeader",
new XElement(sh + "HeaderVersion", "1.0"),
new XElement(sh + "Sender",
new XElement(sh + "Identifier", new object[] {new XAttribute("Authority","EAN.UCC"), "5790000011032"})),
new XElement(sh + "Receiver",
new XElement(sh + "Identifier", new object[] {new XAttribute("Authority","EAN.UCC"), "5790000500000"})),
new XElement(sh + "DocumentIdentification",
new XElement(sh + "Standard", "EAN.UCC"),
new XElement(sh + "TypeVersion", "2.8"),
new XElement(sh + "InstanceIdentifier", "DI-35346-34535-xt435345"),
new XElement(sh + "Type", "catalogueItemNotification"),
new XElement(sh + "CreationDateAndTime", "2013-12-20T10:46:26+00:00")
))
);
doc.Save(savePath);
}
}
}
​

Categories

Resources