xsf and white space - InfoPath Dev
in

InfoPath Dev

xsf and white space

Last post 02-25-2007 09:38 PM by Shiva. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 02-20-2007 12:13 PM

    xsf and white space

    hello everyone,
    I have kind of a wierd problem. I created a utility that will allow the user to make an update inside the manifest.xsf file, the user selects an xsn file, the program unpackages it, makes the change to the manifest.xsf file and repackages the contents back to an xsn file. Here is my problem.
    I try and open the xsn file and i get errors because there are now white spaces that the DTD file is complaining about. So if a child node within the xsf originally looks like:

    <ChildNode attribute="1"></ChildNode>

    it nows looks like

    <ChildNode attribute="1"> </ChildNode>

    and it complains because the schema doesn't recognize the format.

    how on earth can i prevent those white spaces being added to the xml?? here is the code i use to open the xsf, make changes and then save it back.

    xDoc.Load(path + MANIFEST_FILE);
    XmlNodeList nodeList = xDoc.GetElementsByTagName("xsf:adoAdapter");

    for (int i = 0; i < nodeList.Count; i++)
    {
    nodeList.Attributes.GetNamedItem("connectionString").InnerText = this.txtConnectionString.Text;
    }

    xDoc.Save(path + MANIFEST_FILE);

    thanks
  • 02-20-2007 09:57 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694
    Hi Erinselena,

    You have to use below the code before adding the child node.

    For example your chileNode value like:
    //childNode = “<ChildNode attribute="1"> </ChildNode>”;

    IXMLDOMNode newChildNode = childNode.cloneNode(false);

    This will give the new child node with no data (without space).
  • 02-21-2007 06:18 AM In reply to

    Hello Everyone
    This is what i did that worked.

    xDoc.PreserveWhitespace = true;
  • 02-25-2007 09:38 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694
    Hi Erinselena,

    Glad to hear you got it working. Thanks for posting your answer here.
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.