G'day,
I'd think it's something simple but have been trying for ages to remove the underscore that is applied automatically as a suffix to each and every tag.
Does anyone know how to remove?
Thanks,
Tom
I'd think it's something simple but have been trying for ages to remove the underscore that is applied automatically as a suffix to each and every tag.
Does anyone know how to remove?
Thanks,
Tom
コメント
6件のコメント
the underscore is being automatically applied before each element which is stopping data transfer to the end system.
I would expect a simple option to turn this off but I can't find it
There is no way to remove the uderscope in stanard export options. If you need to create a custom xml document you will have to use a script export.
Would you have an example of how the script would look?
I'm guessing a simple find and replace?
Tom.
In order to create xml files you will need to use standard microsoft assmebly - System.Xml in your code.
It will look similar to the follwoing code:
//using System.Text;
using System.Xml;
using System.IO;
string path = @"D:\FCTESTFOLDERS"; //specify export folder
string XmlFileName="TestXML"; //specify filename
if (!File.Exists(path + XmlFileName + ".xml"))
{
XmlTextWriter textWritter = new XmlTextWriter(path + XmlFileName + ".xml", null);
textWritter.WriteStartDocument();
textWritter.WriteStartElement("Start");
textWritter.WriteEndElement();
textWritter.Close();
}
XmlDocument document = new XmlDocument();
document.Load(path + XmlFileName +".xml");
//write to xml
XmlNode Section = document.CreateElement("Node");
document.DocumentElement.AppendChild(Section);
XmlNode Field1 = document.CreateElement("Tag");
document.DocumentElement.LastChild.AppendChild(Fie ld1);
Field1.InnerText = Document.Field("Test\\Field").Text; //write field data
Another approach to creating xml files is to use LINQ to XML.
Timur is correct, it is not possible to switch off this behaviour in FlexiCapture and the only solution is to create your own XML generator in an export script.
Let me explain why it is not possible.
The reason for this is that there are strict rules for XML Tags, for example Tag names can’t start with the letters XML, a number, or punctuation.
The only punctuation allowed is the underscore _.
In FlexiCapture field names can start with a number so to prevent that FlexiCapture creates invalid XML the underscore prefix is used for all XML.
try use LINQ
StringBuilder result = new StringBuilder();
foreach (XElement level1Element in XElement.Load(@"D:\product.xml").Elements("Brand"))
{
result.AppendLine(level1Element.Attribute("name").Value);
foreach (XElement level2Element in level1Element.Elements("product"))
{
result.AppendLine(" " + level2Element.Attribute("name").Value);
}
}
More...Read XML
Hevi
サインインしてコメントを残してください。