How can I get identify an XML header node as an object in code?

In the Catalog.xml demo there is this line:

Paragraph seafoodPara = section2.Paragraphs[“SeafoodTable”];

I want to do the same thing but with a HEADER. So I tried this:

HeaderFooter header = section2.Paragraphs[“Header”];

But got the error: "Paragraph cannot be converted to HeaderFooter"

Do I need to use section2.InsertHeader somehow?

How can I get my XML header node into an object in my code?

Thanks,

Edward

Dear Edward,

Thank you for considering Aspose.

Header is not paragraph. So you should not try to get it in Section.Paragraphs. Accoring to the header definition in you XML, you can get the header of a section through [EvenHeader](http://www.aspose.com/Products/Aspose.Pdf/Api/Aspose.Pdf.Section.EvenHeader.html) or [OddHeader](http://www.aspose.com/Products/Aspose.Pdf/Api/Aspose.Pdf.Section.OddHeader.html).

I finally got a variable in a header to work – however, it requires 7 lines of code, I thought I would be able to do it in one line of code by just referencing the variable, but instead I had to reference the:

section
header
table
row
cell
text
AND THEN finally the segment which contains the code:

Isn’t there a way to just put an ID in a the XML and then access it directly, perhaps with xpath like this:

Dim multiviewTitle As Segment = m_Pdf.Xpath(“section/header/table/row[1]/cell[1]/text[1]/segment”);

Thanks,
Edward



Code that I got to work:

Dim header As Aspose.Pdf.HeaderFooter = CType(m_Section.OddHeader, Aspose.Pdf.HeaderFooter)
Dim tableData As Aspose.Pdf.Table = CType(header.Paragraphs(“TableData”), Aspose.Pdf.Table)
Dim rowData As Aspose.Pdf.Row = tableData.Rows(0)
Dim cellData As Aspose.Pdf.Cell = rowData.Cells(“CellMultiview”)
Dim textMultiview As Aspose.Pdf.Text = CType(cellData.Paragraphs(“TextMultiView”), Aspose.Pdf.Text)
Dim segmentMultiview As Aspose.Pdf.Segment = textMultiview.Segments(“MultiviewTitle”)
segmentMultiview.Content = “from the code2”

Dear Edward,

Thank you for considering aspose.

Maybe I should add a new method:
object GetObjectByID(string ID)
in Pdf or Section. But that requires all ID in Pdf or Section be unique.

That would be a great idea and something we could really use. That is similar to how it is done in JavaScript, for example, with the DOM model.

Another solution might be to use XPath and then access nodes like this:

m_Section.GetObjectByXPath("//uniqueKey");

Either way, having the ability to directly access a node in the XML would greatly improve the flexibility of our reports, since we are doing the XML so that we don’t have to recompile the application everytime the customer wants to reformat a report. But if we have fixed paths in the code to each node, that means the nodes cannot change their order in the XML file.

Thanks,

Edward

Dear Edward,

Thank you for considering Aspose.

Thanks for your advice. I will add this feature in the next fix.

That would be great if you could add this unique ID feature for the Aspose XML.

What is the timeframe on the next fix?

Thanks,
Edward

Dear Edward,

Thank you for considering Aspose.

The next fix will be published in 3 days.

Dear Edward,

Thank you for considering Aspose.

Please download hot fix 1.6.7 here.