コミュニティ

XML document has an underscore in front of each tag <_Tom

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

この記事は役に立ちましたか?

0人中0人がこの記事が役に立ったと言っています

コメント

6件のコメント

  • Avatar
    Permanently deleted user
    ***Prefix sorry.

    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
    0
  • Avatar
    Permanently deleted user
    Hello,

    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.


    0
  • Avatar
    Permanently deleted user
    Thanks Timur,

    Would you have an example of how the script would look?

    I'm guessing a simple find and replace?

    Tom.
    0
  • Avatar
    Permanently deleted user
    It will actually be more complex than that, you can find sample export scripts in help file:Appendix-Using scripts in ABBYY FlexiCapture-scripts for customizing processing-sample scripts.

    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.








    0
  • Avatar
    Permanently deleted user
    Hello Tom,

    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.


    0
  • Avatar
    Permanently deleted user

    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

    0

サインインしてコメントを残してください。