We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

XFA frustration

I’m new to XFA and I’m having some trouble with navigating through a LiveCycle form with Aspose PDF for .NET.

I am trying to get/set some values that are buried several layers down into my form. Here’s what I have done so far: (C#)

Document doc = new Document(“E:\Aspose_In.pdf”);
XmlNode datasets = doc.Form.XFA.Datasets;
If I break I can what I think is the first XFA element, “xfa:datasets”. I see that datasets has 2 child nodes: “dd:dataDescription” and “xfa:data”. Repeating that process I can find the field that
I’m looking for, “linktext”. I’ve tried to build a path several different ways but can’t seem to make it work. Here’s one way:

XmlNode fieldNode = datasets.SelectSingleNode("//datasets/data/MainReport[0]/Page3[0]/item[0]/itemDetail[0]/linktext[0]");
I used this format because I used the code under the “Reading XFA Fields” from the Tips and Tricks page and it gave me the “path” of MainReport[0]/Page3[0]/item[0]/itemDetail[0]/linktext[0], which I’ve already tried as well.

Eventually I need to be able to loop through the “item” to get each of the “linktext” values, but I can’t seem to get the “path” correct so putting an index in wouldn’t help.
In LC Designer I use(JS):
which works perfectly.

Back in C#, if I try and grab the first occurrence of “linktext” I get an “Object reference not set to an instance of an object” error. I assume this is because the syntax of my “path” is incorrect.

Can anyone help me out with this?

I looked at it some more and saw the code posted here. I ran that code thinking I’d get the same type of path that I posted above. But, that was not the case. I got

I also went directly for the field’s data instead of going with
The only other thing I did was to replace all the “/” in my path with "."
After that, I slapped an index on ItemDetails
doc.Form.XFA[“xfa:datasets.xfa:data.MainReport.Items.Item.ItemDetails[” + i + “].DetailsSection.linktxt”];
and then I was able to loop all the way through! Woohoo!

Hi Charlie,

Thanks for contacting support and sorry for the delayed response.

When manipulating form fields, you need to reference the field path using “.” in field path and from your above explanation, I have concluded that now you are able to access form fields inside PDF form. In case you still face the similar issue or you have any further query, please feel free to contact.