I am currently reading a XML but ran into an issue where I need to strip out a file path from an Element value. I have tried wrapping the value in an IF statement with Contains but that is not working. I read the values into a listbox once the application is done getting the values from the elements through the XML Reader. nc:DocumentFileControlID is where I am hitting the file path issue.
XML snippet:
<j:RegisterActionDescriptionText s:id="63196917">5583</j:RegisterActionDescriptionText>
<ecf:FilingPartyID>
<nc:IdentificationID>11333</nc:IdentificationID>
<nc:IdentificationCategoryText>FLEPORTAL</nc:IdentificationCategoryText>
</ecf:FilingPartyID>
</ecf:DocumentMetadata>
<ecf:DocumentRendition>
<ecf:DocumentRenditionMetadata>
<nc:DocumentApplicationName>application/pdf</nc:DocumentApplicationName>
<nc:DocumentFileControlID>C:\Users\Users\Desktop\Summons.pdf</nc:DocumentFileControlID>
<nc:BinarySizeValue>29413</nc:BinarySizeValue>
<ecf:AttachmentSequenceID>2</ecf:AttachmentSequenceID>
</ecf:DocumentAttachment>
</ecf:DocumentRenditionMetadata>
</ecf:DocumentRendition>
C# code using Xml Reader:
while (xr.Read())
{
if (xr.NodeType == XmlNodeType.Element && xr.Name == "nc:DocumentFileControlID")
{
fileToSave = xr.ReadElementString();
if (fileToSave.Contains(".pdf") || fileToSave.Contains(".doc"))
{
//lbFileName.Items.Add(eventCode + "_" + fileToSave);
lbFileName.Items.Add(fileToSave);
fileToSave.Replace("\\", "_");
}
}
No comments:
Post a Comment